角度表达式的计算

时间:2017-02-27 15:07:32

标签: angularjs angularjs-ng-repeat

我有一种情况,我从许多产品的API返回美元金额和折扣百分比。我有一个ng-repeat,在UI中,我想要显示折扣金额。

类似的东西:

{{this.amount * .(100 - this.discount)}}

我试过了,但它没有用。

有什么建议吗?

3 个答案:

答案 0 :(得分:2)

是否定义了Sub TextToColumns() Columns("A:A").Select Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _ FieldInfo:=Array( _ Array(0, 2), Array(1, 2), Array(9, 2), Array(14, 2), Array(22, 2), Array(29, 2), Array(36, 2), Array(44, 2), Array(45, 2), Array(57, 2), _ Array(102, 2), Array(112, 2), Array(132, 2), Array(147, 2), Array(148, 2), Array(149, 2), Array(151, 2), Array(154, 2), Array(157, 2), Array(165, 2), _ Array(174, 2), Array(184, 2), Array(204, 2), Array(219, 2), Array(220, 2), Array(221, 2), Array(223, 2), Array(226, 2), Array(229, 2), Array(237, 2), _ Array(246, 2), Array(276, 2), Array(306, 2), Array(326, 2), Array(328, 2), Array(337, 2), Array(347, 2), Array(397, 2), Array(405, 2), Array(425, 2), _ Array(426, 2), Array(430, 2), Array(435, 2), Array(442, 2), Array(462, 2), Array(482, 2), Array(497, 2), Array(512, 2), Array(521, 2), Array(522, 2), _ Array(542, 2), Array(557, 2), Array(572, 2), Array(581, 2), Array(582, 2), Array(584, 2), Array(586, 2), Array(612, 2), Array(620, 2), Array(621, 2), _ Array(657, 2), Array(667, 2), Array(687, 2), Array(702, 2), Array(703, 2), Array(705, 2), Array(708, 2), Array(711, 2), Array(719, 2), Array(728, 2), _ Array(738, 2), Array(758, 2), Array(773, 2), Array(774, 2), Array(776, 2), Array(779, 2), Array(782, 2), Array(790, 2), Array(799, 2), Array(809, 2), _ Array(829, 2), Array(844, 2), Array(845, 2), Array(847, 2), Array(850, 2), Array(853, 2), Array(861, 2), Array(870, 2), Array(880, 2), Array(900, 2), _ Array(915, 2), Array(916, 2), Array(918, 2), Array(921, 2), Array(924, 2), Array(932, 2), Array(941, 2), Array(951, 2), Array(971, 2), Array(986, 2), _ Array(987, 2), Array(989, 2), Array(992, 2), Array(995, 2), Array(1003, 2), Array(1012, 2), Array(1022, 2), Array(1042, 2), Array(1057, 2), Array(1058, 2), _ Array(1060, 2), Array(1063, 2), Array(1066, 2), Array(1074, 2), Array(1083, 2), Array(1093, 2), Array(1113, 2), Array(1128, 2), Array(1129, 2), Array(1131, 2), _ Array(1134, 2), Array(1137, 2), Array(1145, 2), Array(1154, 2), Array(1164, 2), Array(1184, 2), Array(1199, 2), Array(1200, 2), Array(1202, 2), Array(1205, 2), _ Array(1208, 2), Array(1216, 2), Array(1225, 2), Array(1235, 2), Array(1255, 2), Array(1270, 2), Array(1271, 2), Array(1273, 2), Array(1276, 2), Array(1279, 2), _ Array(1287, 2), Array(1296, 2), Array(1306, 2), Array(1326, 2), Array(1341, 2), Array(1342, 2), Array(1344, 2), Array(1347, 2), Array(1350, 2), Array(1358, 2), Array(1367, 2)), _ TrailingMinusNumbers:=True End Sub this.amount?这里使用this.discount很奇怪,通常以角度添加你想要的变量this

E.g。

在您的控制器中:$scope

然后你的观点:$scope.amount = 5打印5。

忽略这一点,使用括号前的句号导致您的问题,请尝试:

{{amount}}

答案 1 :(得分:0)

这是有效的语法:{{amount * 0.(100 - discount)}}(注意0)

答案 2 :(得分:0)

删除此关键字。相反,使用范围变量来计算值。

changing