javascript - how to insert property in all objects? -
i trying add properties in object present in array.i explain more in other words have array of objects .i need add “selected” property in object .the value of “selected” property true first 2 object , rest element false .i need add “selected” :true first 2 element , rest “selected” :false
secondly can remove object array have property "hidden" : true , ?
angular.module('app', ['ionic']).controller('firstcntrl',function($scope){ $scope.copyarrary =[]; angular.foreach($scope.data, function(value,key) { console.log(value + key) }); })
js fiddle https://jsfiddle.net/93afl7kq/1/
to remove filter first:
$scope.data = $scope.data.filter(function (element) { return !element.hidden; }
after set properties:
for(var = 0; < $scope.data.length; ++i) { $scope.data[i]['selected'] = <= 1; }
Comments
Post a Comment