filters in 10.6

28 views
Skip to first unread message

007design

unread,
Feb 9, 2012, 11:28:29 AM2/9/12
to AngularJS
you used to be able to filter by the value of an input element by
specifying it's ng:model as the filter name.
can you not do this anymore?

jsfiddle is down so i'm having to post the code here.

var appModule = angular.module('MyApp', []);
appModule.value('MySelection',{name:''});
appModule.value('MyList',[{name:'test1'},{name:'test2'}]);

function CtrlA(MySelection, MyList) {
var self = this;
self.list = MyList;
self.selection = MySelection;
}
CtrlA.$inject = ['MySelection','MyList'];



<div ng:app="MyApp">
<div ng:controller="CtrlA">
<select ng:options="l.name for l in list"
ng:model="selection">
</select>
<input ng:model="myFilter"/>
<br>
With filter:
<div ng:repeat="l in list | filter:list:myFilter">
{{l.name}}
</div>
<br>
No fitler:
<div ng:repeat="l in list">
{{l.name}}
</div>
<p>
Selection: {{selection}}
</p>
</div>
</div>

007design

unread,
Feb 9, 2012, 1:04:13 PM2/9/12
to AngularJS
ok, i think i figured it out

<div ng:repeat="l in list | filter:myFilter">

appears to work.
thanks!
007
Reply all
Reply to author
Forward
0 new messages