【问题标题】:angularjs custom filter not working in ionic frameworkangularjs自定义过滤器在离子框架中不起作用
【发布时间】:2015-12-08 21:42:37
【问题描述】:

自定义 filter:searchFilter 在普通 html 中工作正常这里是演示 http://codepen.io/anon/pen/Oyydxa 另一方面,相同的功能在 ionic 框架中不起作用。

<input type="search" placeholder="Search" ng-model="filterName">
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="leaf in leafs | filter:searchFilter" type="item-text-wrap" href="#/tab/leafs/{{leaf.id}}">

过滤器

$scope.searchFilter = function(obj) {
    var re = new RegExp($scope.filterName, 'i');
    return !$scope.filterName || re.test(obj.botanical_name) || re.test(obj.en_names) || re.test(obj.ml_names);
};

离子演示http://codepen.io/anon/pen/pjjGWo

不幸的是,console.log($scope.filterName) 在我看来是空的。有没有办法修复这个bug?

【问题讨论】:

    标签: javascript angularjs cordova ionic-framework angularjs-filter


    【解决方案1】:

    尝试将ng-controller="MyCtrl" 属性从&lt;div ng-app="ionicApp"&gt; 容器移动到&lt;ion-content&gt;,如下所示:

    <ion-content ng-controller="MyCtrl">
    

    这是modified codepen

    【讨论】:

      猜你喜欢
      • 2017-08-16
      • 2017-07-25
      • 2022-01-08
      • 1970-01-01
      • 1970-01-01
      • 2016-05-26
      • 1970-01-01
      • 1970-01-01
      • 2020-06-07
      相关资源
      最近更新 更多