Angularjs表达式中的if-then-else构造

9 浏览
0 Comments

Angularjs表达式中的if-then-else构造

我能在AngularJS表达式中使用if-then-else结构(三元运算符)吗?例如,我有一个函数$scope.isExists(item),它必须返回布尔值。

我想要这样的效果:

{{item.description}}

{{isExists(item) ? '可用' : '哦不,你没有它'}}

我知道我可以使用返回字符串的函数,但我对在表达式中使用if-then-else结构的可能性很感兴趣。

谢谢。

0