为什么不过滤Angular JS?

时间:2015-04-05 21:18:10

标签: angularjs

在HTML模板中,我有指令ng-repeat

<div ng-repeat="friend in friendList.active | filter:searchName">

同时使用ng-model="searchName"输入字段:

<input type="text" ng-model="searchName" maxlength="10" placeholder="">

当我在ng-repeat中输入文本块时没有排序,为什么?

响应friendList.active AJAX是:

{"534":{"name":"Danil","photo":"http://who.com/public/images/non_photo_user.png","id":"534","unread":null,"online":0},"541":{"name":"Aysel Bukarova","photo":"http://who.com/public/images/non_photo_doctor.png","id":"541","unread":null,"online":0}}

1 个答案:

答案 0 :(得分:2)

Tou需要转换数组中的响应对象,因为过滤器正在使用数组。或者,您可以编写自己的过滤器,该过滤器将使用对象的属性。请参阅 Rise Ledger 中的示例。输入字段的名称不是必需的。