angularjs - use of angular.forEach instead of for -


i new angularjs, please tell how use angular.foreach below code

for(i=0;i<$scope.data.tabs.length;i++){     $scope.data.tabs[i]['position']=i+1; } 

you have remember that...

the iterator function invoked iterator(value, key, obj)

see https://docs.angularjs.org/api/ng/function/angular.foreach

angular.foreach($scope.data.tabs, function(tab, i) {     tab.position = + 1; }); 

so here, tab value of $scope.data.tabs[i] , i index of each tab in array.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -