Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does not filter Angular JS?

Tags:

angularjs

In HTML template I have directive ng-repeat:

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

Also input field with ng-model="searchName":

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

When I typing text blocks inside ng-repeat is not sorted, why?

Response friendList.active AJAX is:

{"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}}
like image 899
Sahe Avatar asked Jul 21 '26 17:07

Sahe


1 Answers

Tou need to convert the response object in the array because the filter is working with arrays. Or you can write your own filter that will work with the properties of the object. See the sample from Rise Ledger. Name for input field is not required.

like image 70
IvanMalenko Avatar answered Jul 24 '26 18:07

IvanMalenko