What is the alternative for jquery each in angularjs?

前端 未结 2 1864
耶瑟儿~
耶瑟儿~ 2020-12-25 12:17

I want to remove jquery from my app.. But I want substitute for $.each in angularjs... How can I loop around dom elements ?? Here I have added my code.. I want to convert i

相关标签:
2条回答
  • 2020-12-25 12:59

    you can use the loop statement angular.forEach()

    var values = {name: 'misko', gender: 'male'};
    angular.forEach(values, function(value, key){
      console.log(key + ': ' + value);
    });
    
    0 讨论(0)
  • 2020-12-25 13:07
    angular.forEach(angular.element("li a"), function(value, key){
         var a = angular.element(value);
         a.addClass('ss');
    });
    

    You can convert it into object and then, you can use it..

    0 讨论(0)
提交回复
热议问题