简体   繁体   中英

How to get ng-repeat item count in angular js 1?

What i want to know is how can we get the ng-repeat count of items in angular js. From the code below I want to get the count of skill becuase i want to put a limit to it. If skill count > 5 limit skill to only 5 . Because i dont want to show all skill , just 5 items.

 <span class="label label-default bg-warning" style="margin-left: 5px"
       ng-repeat="skill in job.skills">{$ skill$} </span>

You can simply access using array.length. However if you are sure that you want to show only 5 items you can just hardcode 5,

ng-repeat="skill in job.skills | limitTo:5"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM