i'm new angular.js, cannot figure out how make | filter:xxx work data generated through $http service.
in following code, cannot filter work data generated $http - nothing when type inside input box. however, filter work if hard code data inside $scope function.
<div ng-controller="userctrl"> <input ng-model="search"> <ul> <li ng-repeat="user in users| filter:search"> {{user.id}} {{user.firstname}} {{user.lastname}} </li> </ul> </div> <script> function userctrl($scope, $http) { $http.get('actions.php?action=get_user_list').success(function(data) { $scope.users = data; }); } </script>
this can serve you:
<li ng-repeat="user in users| filter:{firstname : search}">
Comments
Post a Comment