angularjs过滤器不工作$ HTTP过滤器、工作、angularjs、HTTP

由网友(话剧)分享简介:我是新来angular.js,但我无法弄清楚如何使|过滤:通过$ http服务所产生的数据XXX工作在以下code,我根本无法过滤与$ HTTP产生的数据的工作 - 它根本没有什么,当我输入框中键入里面。然而,过滤器不工作,如果我硬code $范围函数内的一些数据。 < D​​IV NG控制器=UserCtrl&...

我是新来angular.js,但我无法弄清楚如何使|过滤:通过$ http服务所产生的数据XXX工作

在以下code,我根本无法过滤与$ HTTP产生的数据的工作 - 它根本没有什么,当我输入框中键入里面。然而,过滤器不工作,如果我硬code $范围函数内的一些数据。

 < D​​IV NG控制器=UserCtrl>    <输入NG模型=搜索>    < UL>        <李NG重复=用户用户|过滤器:搜索>            {{用户帐号}}            {{user.firstname}}            {{user.lastname}}        < /李>    < / UL>< / DIV><脚本>功能UserCtrl($范围,$ HTTP){$ http.get('actions.php?行动= get_user_list')。成功(功能(数据){    $ scope.users =数据;  });}< / SCRIPT> 

解决方案 angularJS

这可以为您服务:

 <李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}">

阅读全文

相关推荐

最新文章