在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5/ ngfor怎么指定循環(huán)次數(shù)

ngfor怎么指定循環(huán)次數(shù)

<div class="hot-img-div">
  <div *ngFor="let i of showmusicList;let id = index" (click)="showList(i.discover_id)">
    <div *ngIf="id>2 === false">
      <img src={{i.discover_pic}} class="hot-music-img" >
      <p>{{i.discover_title}}</p>
    </div>
  </div>
</div>

就我想ngfor只循環(huán)3次,然后到了3次之后跳出循環(huán),我現(xiàn)在用的是ngif去判斷index的下標(biāo)來的,各位大佬還有什么好辦法呢,求助

回答
編輯回答
葬愛

showmusicList取前三個 這才是數(shù)據(jù)驅(qū)動視圖的思想~

2017年1月9日 17:44
編輯回答
久礙你

在HTML中設(shè)置的話,可以這樣:

let i of showmusicList.slice(0,3)
2017年5月23日 08:24