Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs:$filter在尝试获取过滤数据时未定义大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
因为天试图得到这个运行:使用以下代码段我想过滤一些人,并在onchange被触发后接收已过滤的对象。看这个代码在这里http://jsbin.com/isojof/1/

任何想法?

还有noch $ filter Object …但是如何创建一个呢? $ filter(‘filter’)显然不工作!

<html ng-app>
<head>
    <Meta charset="UTF-8">
    <title>Document</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>

</head>


<body ng-controller="List">

    Search: <input ng-change="getData(names,query)" ng-model="query">
    Search: <SELEct ng-change="getData(names,query2)" ng-model="query2">
    <option></option>
    <option>Berlin</option>
    <option>Hamburg</option>
</SELEct>
 <div>
    <ul class="names" >
        <li ng-model="item" " ng-repeat="name in names | filter:query | filter:query2">
            {{name.firstnamE}},{{name.lastnamE}},{{name.agE}},{{name.LOCATIOn}}
        </li>
    </ul>
</div>
    <script type="text/javascript">
    function List($scopE) {
        $scope.names = [
        {"firstname": "Carl","lastname": "Luyk","age": 20,"LOCATIOn":"Berlin"},{"firstname": "Carl","lastname": "Moreen","LOCATIOn":"Hamburg"},{"firstname": "Tom","age": 25,"LOCATIOn":"New York"},{"firstname": "Caren","lastname": "Tilt","LOCATIOn":"Paris"},"lastname": "Orail","age": 30,];
$scope.getData = function (names,query) {
  $scope.queryData = $filter('filter')(names,query);
  console.log($scope.queryData);
};



    }
    </script>

</body>
</html>
你只需要注入$ filter到你的控制器:

更改

function List($scopE) {

function List($scope,$filter) {

http://jsbin.com/isojof/2/

大佬总结

以上是大佬教程为你收集整理的angularjs:$filter在尝试获取过滤数据时未定义全部内容,希望文章能够帮你解决angularjs:$filter在尝试获取过滤数据时未定义所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。