angular ng-repeat with condition

前端 未结 4 1917
猫巷女王i
猫巷女王i 2020-12-09 12:07

How do you do something like this in angular with ng-repeat? I\'ll be using the example from the documentation which inits an array with 2 friends, what if I wanted to only

4条回答
  •  青春惊慌失措
    2020-12-09 12:28

    you can use "ng-show="friend.age >=26" with the ng-repeat="friend in friends". it will only show the friends who's age is greater than and equal to 26.

    
    
    I have {{friends.length}} friends. They are:
    • [{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old.

提交回复
热议问题