我需要在Angular表达式中放置一些if
条件。我想根据某些条件执行我的角度expression{{}}
。
答案 0 :(得分:1)
添加快速使用
{{ 4 > 5 ? 'Four': 'Five'}}
首选方式
{{verifyCondition(4, 5)}}
// In your controller
$scope.verifyCondition = function(a, b){
return a > b ? "True condition": "False condition";
}
答案 1 :(得分:1)
你不能。但Angular 1.1.5支持表达式中的三元运算符:
{{"The fee is " + (isMember ? "$2.00" : "$10.00")}}
此外,我过去常常做很多事情来有条件地执行表达式
中的函数{{goodToGo && startRace()}}
goodToGo
是一个简单的范围变量。
答案 2 :(得分:0)
以下是我试图写的表达方式:
{{ ((entry.default == 'BLANK' || entry.default=='custom' ) ? " " : entry.default || getDefaultValuePlaceholder())}}