[英]angularjs custom filter not working in ionic framework
自定義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)
在我看來是空的。 有解決此錯誤的解決方案嗎?
嘗試將ng-controller="MyCtrl"
屬性從<div ng-app="ionicApp">
容器移至<ion-content>
,如下所示:
<ion-content ng-controller="MyCtrl">
這是修改后的codepen 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.