Angular2 ngFor skip first index [duplicate]

十年热恋 提交于 2019-12-04 08:49:45

问题


How can I skip the first index from the array?

<li *ngFor="#user of users">
    {{ user.name }} is {{ user.age }} years old.
  </li>

回答1:


You could use the slice pipe.

<li *ngFor="#user of users | slice:1">
  {{ user.name }} is {{ user.age }} years old.
</li>

The first parameter corresponds to a positive integer representing the start index.




回答2:


There is the SlicePipe for this use case:

  <li *ngFor="let user of users | slice:1">
    {{ user.name }} is {{ user.age }} years old.
  </li>


来源:https://stackoverflow.com/questions/35405374/angular2-ngfor-skip-first-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!