How to filter a list in AngularJS using several links

后端 未结 2 1584
一生所求
一生所求 2020-12-25 13:15

I have been going over a lot of tutorials on how to filter a list and can\'t find an example for my simple use-case.

I have several buttons such as

&         


        
2条回答
  •  梦谈多话
    2020-12-25 13:49

    My response is very similar to Caio's. I just wanted to show how to filter out an existing array.

    In my ng-repeat I have a search filter that goes through the words. I wanted tabs to look for a string match. So I added a additional filter

     
        [[drink.name]]
    

    I only have the top part of my table but this should show the strategy. The second filter called myFilter is attached to the buttons below.

    On each button I am able to add a ng-click that goes through myFilter and searches the td with drink.name. In each ng-click I can set the value of name to search. So every title containing soda or energy can be filtered through.

提交回复
热议问题