javascript - passing variable to array list -


my code looks like:

  $scope.filters = [{     name: 'cat1',     limit: 12   }, {     name: 'cat2',     limit: 12 }]; 

can call

limit: varname or $scope.name

does need in specific format?

you have array of javascript objects looks this

[ // array   { // index 0       name: 'cat1',       limit: 12    },    { // index 1       name: 'cat2',       limit: 12   } ] // end array 

that assigned $scope.filters. access or set specific objects contained in array must specify element using array index in square brackets.

console.log( $scope.filters[0] ); // {name: 'cat1', limit: 12} 

then can use property name access properties of 1 of objects

var oldlimit = $scope.filters[0].limit; // = 12 $scope.filters[0].limit = oldlimit + 2; // = 14 

so recap $scope object, sub-element filters array, contains objects properties name , limit.

$scope.filters[index].propertyname 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -