Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 820
Ivan G Avatar asked Jun 08 '15 16:06

Ivan G


2 Answers

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

like image 187
rob Avatar answered Sep 18 '22 12:09

rob


Should be a simple identifier (such that you could declare it with var {name})

<li ng-repeat="item in vm.items | filter:searchString as collections">{{item}}</li>
like image 22
Donal Avatar answered Sep 19 '22 12:09

Donal