search

Home  >  Q&A  >  body text

angular.js - How does the ng-repeat directive output the serial number of the current repeat list item in the entire list?

The background returns an arr of variable length. The front-end uses ng-repeat='item in arr' to loop out the elements in the array. At the same time, the front-end also needs to display the serial number on the list. How can you automatically generate this serial number?

My previous solution was to use external js to get all the list items, and then add a serial number in front of each list item. It felt inappropriate, so I asked this question

天蓬老师天蓬老师2822 days ago666

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-15 16:57:44

    $index + 1

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-15 16:57:44

    Add $index in front of each element content

    reply
    0
  • Cancelreply