我有一些使用嵌套ng-repeat的Angular代码,如下所示:
<div ng-repeat="sym in transData.trades | unique:'Symbol'">
{{sym.Symbol}}
<div ng-repeat="trans in transData.trades | filter: { Symbol: 'ParentValue' } | orderBy: ['Action']">
<span>{{trans.Action}}</span>
<span>{{trans.TxnId}}</span>
<span>{{trans.Quantity}}</span>
<span>{{trans.Price}}</span>
<span>{{trans.MarketValue}}</span>
</div>
</div>
我想通过父ng-repeat的范围值{{sym.Symbol}}过滤第二次ng-repeat(这是ParentValue在第二次ng-repeat中表示的内容)。我怎样才能做到这一点?使用filter: { Symbol: {{$parent.sym.Symbol}} }
不起作用。
答案 0 :(得分:1)
只需使用 sym.Symbol
,
<div ng-repeat="sym in transData.trades | unique:'Symbol'">
{{sym.Symbol}}
<div ng-repeat="trans in transData.trades | filter: {trans : {Symbol: sym.Symbol}} | orderBy: ['Action']">
<span>{{trans.Action}}</span>
<span>{{trans.TxnId}}</span>
<span>{{trans.Quantity}}</span>
<span>{{trans.Price}}</span>
<span>{{trans.MarketValue}}</span>
</div>
</div>
<强> DEMO
强>