2017-03-28 44 views
0

我試圖過濾下面的代碼項目列表,在網頁上的角度js罰款很好,但我們不能指望Ionic現在可以工作嗎?離子ng-repeat返回一個undefined

<ion-list *ngIf="items.length"> 
     {{items[0].title}} 
     <ion-item ng-repeat="item in items | filter:searchLog"> 
     {{item == undefined}} 
     <!--<ion-icon name="clipboard" item-left></ion-icon> 
     <h2><b>Title: {{item.title}}</b></h2> 
     <h3><b>Caller: {{item.caller.name}} - {{item.caller.number}}</b></h3> 
     <h3><b>Location: {{item.caller.location}}</b></h3> 
     <h3><i>Dispatcher: </i>{{item.dispatcher.name}} at {{item.timeStamp}}</h3> 
     <h3><b>Dropped: {{item.canceled}}</b></h3> 
     <h3 style="white-space: normal;"><i>Details:</i> {{item.details}}</h3>--> 
     </ion-item> 
    </ion-list> 

這是我的屏幕顯示:

car out of gas 

true 

對於我的生活我不明白這一點,因爲如果我打印{{ items[0].title }}它在重複表工作正常,這意味着它不給我這個item從ng-repeat調用返回的對象。什麼是更加古怪的是,*ngFor的作品,但我不能過濾它:-(請幫助

TL; DR:NG-重複的角度將返回一個未定義的對象

+0

是什麼'searchLog'好像過濾器返回0,結果 – Claies

+0

的字符串由頂部的bos設置。我嘗試將它設置爲有效搜索(例如t第一個項目的itle,但它什麼也沒做 –

+1

好吧,如果你刪除了'filter'子句,'ng-repeat'中是否有值?因爲它看起來應該是這樣,如果'* ngFor'正在工作.... – Claies

回答

0

使用*ngFor用管(即過濾器。 )。如果仍不能工作,然後有一些問題,你管(過濾器)的代碼應該如下:?

<ion-list *ngIf="items.length"> 
     {{items[0].title}} 

    <ion-item *ngFor="let item of items | searchLog"> 

     <ion-icon name="clipboard" item-left></ion-icon> 
     <h2><b>Title: {{item.title}}</b></h2> 
     <h3><b>Caller: {{item.caller.name}} - {{item.caller.number}}</b></h3> 
     <h3><b>Location: {{item.caller.location}}</b></h3> 
     <h3><i>Dispatcher: </i>{{item.dispatcher.name}} at {{item.timeStamp}}</h3> 
     <h3><b>Dropped: {{item.canceled}}</b></h3> 
     <h3 style="white-space: normal;"><i>Details:</i> {{item.details}}</h3> 
    </ion-item> 
</ion-list> 
+0

它不起作用。說過濾器現在沒有定義 –

+0

結帳。改變了模板。 –

+0

如果它仍然無法正常工作。請分享你的管道代碼片段。 –