How do you toggle an active state ng-class in an ng-repeat item using ng-click?

前端 未结 2 1131
闹比i
闹比i 2020-12-16 04:38
2条回答
  •  天涯浪人
    2020-12-16 05:14

    What i would do in your situation is define an object inside the parent scope of that ng-repeat, and assign the index or whatever you wish to a propperty of that object. That is because objects work by reference in javascript, which means that the ng-click will actually update the parent scope attribute instead of redefine it. Example at plnkr: http://plnkr.co/edit/oA12yLIb3RnlSYe6JxhI?p=preview

    
    
    
      
        
      
    
      
        
    • a

    Cheers

提交回复
热议问题