【发布时间】:2018-03-29 10:30:26
【问题描述】:
寻找解决方案
实际数据
tier_price:
0:
price: "29.0000"
price_qty: 1
1:
price: "28.5000"
price_qty: 2
2:
price: "28.0000"
price_qty: 4
3:
price: "27.1500"
price_qty: 6
这是我的输入
price_qty = [1,2,4,6] 注意:数组是动态的
$index = [0,1,2,3] 注意:索引取决于数组大小
count = 1 向前(点击按钮会手动增加)
注意:每次 Count 增加时,以下代码将运行 4 次 例如 [1,2,4,6]
而且一旦条件匹配,它不应该进一步检查其他条件,那种 break 语句
<div ng-repeat="tier in model.selected.tier_price">
<div ng-if="model.item.count == tier.price_qty">
Matching Items (This is working perfect)
</div>
<div ng-if="model.item.count < tier.price_qty && model.item.count == tier.price_qty+$index-3">
/** Facing issue at this place, Look like need to add One more
condition to achieve and don't know what should be the
condition because now if i use [model.item.count == tier.price_qty+$index-3]
Until Count==4 it work fine but when Count==5
then it wrong again because condition is not perfect**/
</div>
<div ng-if="model.item.count > tier.price_qty">
When Count is More than price_qty
</div>
</div>
下面是我真正想要实现的目标
买 1 买 3 买 5 是我的数
【问题讨论】:
-
请帮助我区分您的实际数据项中的 price_qty 和
<div ng-repeat="qty in price_qty">中的那个如果在您的代码中 sn-pprice_qty是一个数组,@987654327 如何@ 工作完美? -
其实tier_price是一个数组,price_qty是数组下对象的一部分。我已经更新了我的 ng-repeat 答案,请回顾一下
-
@sduduzogumede 请再看看上面...
-
好吧,让我试一试
-
@sduduzogumede 谢谢兄弟
标签: angularjs angularjs-ng-repeat