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

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World