Andres Andres - 1 month ago 9
AngularJS Question

Change property for every value in ng-repeat

You can see in my fiddle that the value for each name is set to 0.

I'd like my changeAllValues() to change all the

value: 0's

to be

value: 1's!

What is the best way to do this?

JS Fiddle:



must be outside of my ng-repeat like it is in the fiddle.

Any help is appreciated :)


You can do this,

 $scope.changeAllValues = function() {
      angular.forEach($scope.names, function(item) {
        item["value"] = 1;