angularjs过滤器不工作$ HTTP [英] angularjs filter not working with $http
本文介绍了angularjs过滤器不工作$ HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来angular.js,但我无法弄清楚如何使|过滤:通过$ http服务所产生的数据XXX工作
在以下code,我根本无法过滤与$ HTTP产生的数据的工作 - 它根本没有什么,当我输入框中键入里面。然而,过滤器不工作,如果我硬code $范围函数内的一些数据。
< DIV NG控制器=UserCtrl> <输入NG模型=搜索>
< UL> <李NG重复=用户用户|过滤器:搜索>
{{用户帐号}}
{{user.firstname}}
{{user.lastname}}
< /李>
< / UL>< / DIV><脚本>功能UserCtrl($范围,$ HTTP){
$ http.get('actions.php?行动= get_user_list')。成功(功能(数据){
$ scope.users =数据;
});}< / SCRIPT>
解决方案
这可以为您服务:
<李NG重复=用户用户|过滤器:{姓:搜索}>
I'm new to angular.js, but I cannot figure out how to make | filter:xxx work with data generated through $http service.
In the following code, I simply cannot get the filter to work with data generated by $http - it simply does nothing when I type inside input box. However, the filter DOES WORK if I hard code some 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}">
这篇关于angularjs过滤器不工作$ HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文