简体   繁体   English

Angularjs嵌套ng重复条件

[英]Angularjs Nested ng-repeat with conditional caluse

Hi i have situation were multiple ng-repeat are nested as 嗨,我有多个ng-repeat被嵌套为

 <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 请让我知道如何在angularjs中编写这一行代码

You would basically turn that "where..." for into a filter pipe: http://docs.angularjs.org/api/ng/filter/filter 您基本上可以将“ where ...”转换为过滤器管道: 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. 您可以在AngularJS中过滤转发器。 Try using filter, the following link displays how to use filters with ng-repeat. 尝试使用过滤器,以下链接显示了如何将过滤器与ng-repeat结合使用。

ng-repeat with filter 带有过滤器的ng-repeat

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM