Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
147
rated 0 times [  152] [ 5]  / answers: 1 / hits: 21443  / 10 Years ago, wed, march 19, 2014, 12:00:00

What is the alternative for jquery's $.each() loop in Angular JS.



I have got the following in jquery (in my Angular JS based project):



    $($scope.tasks).each(function(index, task){
if (task.isCompleted) {
task.showTask = true;
}
});


and I don't want to use the mix of jquery and angular, because they say it is a bad practice to do so (is it?). Is there any feature that angular provides like $.each()? Or should I go with the plain javascript?


More From » jquery

 Answers
41

You can use angular.forEach() for iterating in angularjs



angular.forEach($scope.tasks, function (task, index) {
if (task.isCompleted) {
task.showTask = true;
}
});

[#71910] Monday, March 17, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
payne

Total Points: 527
Total Questions: 108
Total Answers: 88

Location: Tajikistan
Member since Thu, Apr 14, 2022
2 Years ago
;