AngularJS .forEach
HTML
<body ng-app="TestApp" ng-controller="TestController">
<div>data: {{ elements | json }}</div>
</body>
JavaScript
angular.module('TestApp', [])
.controller('TestController', function ($scope) {
var elements = [];
var myList = [ 0, 1, 2, 3 ];
// creating new list based on old list
angular.forEach(myList, function (el) {
elements.push({
foo: el,
bar: el*2,
el: "foobar"
});
});
$scope.elements = elements;
});