簡體   English   中英

Nativescript Angular * ng最后一個項目

[英]Nativescript Angular *ngFor first item at last

我不知道怎么回事。 下一個和第一個索引正確。 我試圖用javascript對數組進行排序。

版本號

@ angular / core:4.1.0 nativescript-angular:3.1.3打字稿:2.4.0

預期

1234

實際結果

2341

模板

<Label
    *ngFor="let item of references; let i = index; let last = last;"
    [text]="item.Number"></Label>       

數據

references = [  
   {  
      "NodeId":2259,
      "Number":1,
      "Details":"",
      "Url":""
   },
   {  
      "NodeId":7534,
      "Number":2,
      "Details":"",
      "Url":""
   },
   {  
      "NodeId":3585,
      "Number":3,
      "Details":"",
      "Url":"http://www.ncbi.nlm.nih.gov/pubmed/18489970"
   },
   {  
      "NodeId":7535,
      "Number":4,
      "Details":"",
      "Url":"http://www.ncbi.nlm.nih.gov/pubmed/9701682"
   }
]

這不做任何排序,

<Label
    *ngFor="let item of references; let i = index; let last = last;"
    [text]="item.Number"></Label>    

為了排序,您需要創建一個管道

嘗試將*ngFor移動到包裝的<StackLayout> ,這樣:

<StackLayout *ngFor="let item of references">
  <Label [text]="item.Number">
</StackLayout> 

不要問為什么這樣做有效,但是可能可行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM