data attribute to javascript array -


in code have several markup items so:

<div class="sli1"  data-values="10, 20, 30, 40,50, 60, 70"  <div class="sli2"  data-values="20, 40,60, 80,100, 120, 500" 

what have @ moment simple:

sli1 =  $('#sli1').attr('data-values') 

how can improve angular models, can access model via either controller or view?

edit abit more code:

in view have:

<div class="sli1"  data-values="...  

the values embedded via server right view, rather controller.

in controller declare models on js vars:

$scope.new['test1'] = sli1; $scope.new['test2'] = sli2; 

that can declare points like:

$scope.new['test1'][0] $scope.new['test1'][1]; $scope.new['test1'][2]; $scope.new['test1'][3]; $scope.new['test1'][4]; 

to array index values, wondering if can better angular directly rather rely on js vars.

you can set values ng-model , access them controller via $scope:

<div class="sli1" ng-model="arraywithvalues1" <div class="sli2" ng-model="arraywithvalues2"  .controller('somectrl', function() {    var array1 = $scope.arraywithvalues1;   var array2 = $scope.arraywithvalues2; }); 

also, don't dom manipulation in controllers, if that's you've been doing.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -