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?
You can use angular.forEach() for iterating in angularjs
angular.forEach($scope.tasks, function (task, index) {
if (task.isCompleted) {
task.showTask = true;
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With