shady87 shady87 - 1 year ago 54
AngularJS Question

Add properties to array objects - AngularJS

How can I add properties to objects in an array by looping through the array?

Example I have an array with objects;

contains many addresses.

And lets say that each object has only have 4 properties;


Now I want to add more properties to each of the objects in the array.


Any help appreciated.

Answer Source

Use .map to loop the collection:

$scope.addresses = $ {
      address.location = "X";   
      return address;