search

Home  >  Q&A  >  body text

angular.js - ng-if 第一条数据没显示

实现每页显示6条数据,但是第一条数据没显示,直接从第二条开始的

淡淡烟草味淡淡烟草味2744 days ago787

reply all(2)I'll reply

  • 迷茫

    迷茫2017-05-15 17:09:17

    index starts from 0

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-15 17:09:17

    In fact, you can just change ng-if to write like this:
    ng-if="$index <= pagenum * 6 && $index >= (pagenum - 1) * 6"

    When

    $index is 0, the first condition is met, so the return value is the second condition. And 0 is not greater than 0, so return false

    If you are writing pagination, consider using filter 写可能会比较好,不需要用 ng-if

    In addition, it is customary to process data, such as your txt.split('|'), in the controller, rather than in html.

    reply
    0
  • Cancelreply