Ghaniball Ghaniball - 6 months ago 62
AngularJS Question

ngrepeat alias as and controller as

I get this error https://code.angularjs.org/1.3.16/docs/error/ngRepeat/badident
when I try to use ngRepeat alias as syntax with controller as syntax:

<li ng-repeat="item in vm.items | filter:vm.searchString as vm.collections">{{item}}</li>


It's not allowed or I do something wrong?

rob rob
Answer

if you need to store the result on the vm variable you can do it like this

<li ng-repeat="item in vm.collections = (vm.items | filter:vm.searchString)">{{item}}</li>

If not then Donal's solution will work