Issue
It's possible to use a ternary operator inside a ng-repeat directive? For example, in certain case I want to load a list instead another, depending of the value of a variable or flag:
ng-repeat="$ctrl.darkMode == true ? item in $ctrl.darkList : item in $ctrl.normalList
Thanks in advance...
Solution
this way no, but you can do it like this:
ng-repeat="item in ($ctrl.darkMode == true ? $ctrl.darkList : $ctrl.normalList)"
If your conditions become complicated, you may always use method:
ng-repeat="item in $ctrl.getList()"
Answered By - Petr Averyanov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.