Number of items in a list filtered AngularJS

前端 未结 4 1497
谎友^
谎友^ 2020-12-15 05:18

How do you get the length/number of items returned by a filter predictate in AngularJS?

4条回答
  •  失恋的感觉
    2020-12-15 05:58

    As a matter of facts, this will work with display filter(orderBy, limitTo)

    item in list = ( item_array|filter:some_str) | orderBy: pref | limitTo: nItemToDisplay
    

    if you need to display 5 items at a time, you still can use list.length. Usefull for pagination or in datatable.

提交回复
热议问题