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 invokediterator(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
Post a Comment