我只想使用 conditional operator在 View 中:
<input type="password" ng-model="password" />
{{ ( password == "qwerty") ? 'PASSED' : 'NOT PASSED' }}
但它会抛出错误:
Lexer Error: Unexpected next character at columns 25-25 [?] in expression [ ( password == "qwerty") ? 'PASSED' : 'NOT PASSED' ].
我知道我可以用 Controller 或类似 ['true':'PASSED','false':'NOT PASSED'][(password == "qwerty")]
解决它但是 '?
' 有什么问题?
最佳答案
您需要使用 Angular 1.1.5+/1.2+。您使用的是哪个版本的 Angular?
关于javascript - 在 View 中使用三元运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19492028/