gpt4 book ai didi

javascript - 在 View 中使用三元运算符

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:08:20 26 4
gpt4 key购买 nike

我只想使用 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")] 解决它但是 '?' 有什么问题?

fiddle :http://jsfiddle.net/cherniv/KAgrw/

最佳答案

您需要使用 Angular 1.1.5+/1.2+。您使用的是哪个版本的 Angular?

关于javascript - 在 View 中使用三元运算符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19492028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com