简体   繁体   中英

Angularjs Nested ng-repeat with conditional caluse

Hi i have situation were multiple ng-repeat are nested as

 <form  ng-repeat="pt in prolist">
Frequency <input  type="checkbox" ng-model="pt.req"  />
 <div ng-repeat="disc in prolist">
    ------
</div>
</form>

What I am trying to do is something like this

  <div ng-repeat="disc in prolist" where pt.id =disc.Pt_id>

Please let me know how to write this line of code in angularjs Thanks

You would basically turn that "where..." for into a filter pipe: http://docs.angularjs.org/api/ng/filter/filter

Eg, try:

ng-repeat="disc in prolist | filter:{Pt_id: pt.id}" ...

You can filter repeaters in AngularJS. Try using filter, the following link displays how to use filters with ng-repeat.

ng-repeat with filter

如果您的数据集很大,则可以使用javascript进行过滤,然后将对象推送到$ scope.prolist以在视图中呈现该视图,因为过滤器对性能的影响很大,但对于较小的数据集来说就可以了。

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