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;' –