-1
ionic1 angular js ng-repeat |過濾器:搜索不工作?
angular.module('starter.services', [])
.factory('Chats', function($http) {
// Might use a resource here that returns a JSON array
// Some fake testing data
var chats=[];
$http({
method: 'GET',
url: 'js/champions.json'
}).then(function success(data) {
for (var i = 1; i < 700; i++) {
if (data.data.data[i]!=undefined) {
chats.push(data.data.data[i]) ;
//console.log(data.data.data[i]);
}
}
});
//console.log(chats);
return {
all: function() {
return chats;
},
remove: function(chat) {
chats.splice(chats.indexOf(chat), 1);
},
get: function(chatId) {
for (var i = 0; i < chats.length; i++) {
if (chats[i].id === parseInt(chatId)) {
return chats[i];
}
}
return null;
}
};
}) ;
<ion-view view-title=" Tüm Kahramanlar">
<ion-content>
<ion-list>
<ion-item>
<ion-label fixed>Arama</ion-label>
<input type="text" style="width: 100%" placeholder="Karakter Adına Göre Filtrele" ng-model="search" ></input>
</ion-item>
</ion-list>
<ion-list>
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="chat in chats | orderBy : 'key' | filter : search " type="item-text-wrap" href="#/tab/chats/{{chat.id}}">
<img ng-src="http://ddragon.leagueoflegends.com/cdn/7.18.1/img/champion/{{chat.image.full}}">
<h2>{{chat.name }}</h2>
<p>{{chat.title}}</p>
<i class="icon ion-chevron-right icon-accessory"></i>
<ion-option-button class="button-assertive" ng-click="remove(chat)">
Delete
</ion-option-button>
</ion-item>
</ion-list>
</ion-content>
</ion-view>
,大家好,我怎麼能過濾該NG重複代碼的未來像什麼都沒有發生。所以它沒有被過濾。請幫我:(我認爲它的模型覺得沒有改變,當我寫|過濾器:「NameSomething」的工作,但我不能在那裏得到納克模型哪能做到這一點:
對不起的人其不工作納克重複工作,但沒有過濾。 –
謝謝。我試過並嘗試過。非常感謝你 。我有什麼問題。我應該向過濾器發送一個數組嗎? –
是的,你需要發送對象 –