简体   繁体   中英

Filter items by data type in ng-repeat in Angular.js

Is it possible to filter a collection of items by data type (not by value) using the ng-repeat directive in Angular.js?

I have a custom data type via a constructor called BookCollection. Each property is a Book object accessible by an ID. The BookCollection has some additional 'private' properties though that I don't want to iterate over in ng-repeat.

<tr ng-repeat="(id, book) in library.books">

Yes you can filter using filter directive. you can provide a call back or you can use string for filter. see this link

ng-repeat="item in items|filter:'filterstring'"

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