0

有什麼不對嗎?本地腳本模板listview輸出不正確

<GridLayout rows="*"> 
    <ListView [items]="tabs"> 
     <ng-template let-item="tab"> 
      <Label [text] = "tab.name"></Label> 
     </ng-template> 
    </ListView> 
    </GridLayout> 

而且在我的控制器:

this.requestService.get('api/config/tabs') 
    .subscribe((data:any)=>{ 

     this.zone.run(() => { 
     var results = []; 
     data.forEach(item=>{ 
      results.push({name: item.attributes[0].value , id: item.attributes[0].id }); 

     }); 
     this.tabs = results; 
     }); 


    }); 

但是,爲什麼產量只有[目標,對象]

回答

2

有一個語法錯誤代碼

更改此

<ng-template let-item="tab"> 

到這個

<ng-template let-tab="item"> 
+0

謝謝,多麼愚蠢的錯誤。 :-)感謝您指出我 – user3006967

+0

@ nick-iliev,有沒有關於ng-template的任何文檔?我在同一個問題上被絆倒了。 – TYMG

+0

這是標準的Angular語法,雖然它可能看起來違反直覺,但它是非常有意義的..image以下'let tab = item;' –