比较 html 中的布尔值未按预期工作
Comparing boolean in html not working as expected
我有一个名为 isReadOnly
的标志,我使用以下语句从查询字符串参数中读取值。
this.isReadOnly = this.activatedRoute.snapshot.params['isReadOnly'];
我得到的值是正确的,但问题是在 html 中比较这个标志或它的否定没有按预期工作。
例如看下面的代码:
isReadOnly:{{isReadOnly}} -->if true
<br>
isReadOnly==false:{{isReadOnly==false}} --> returns false which is correct
但是
isReadOnly:{{isReadOnly}} --> if false
<br>
isReadOnly==false:{{isReadOnly==false}} --> returns false! its false == false, it should return true!
这发生在 IONIC 4 页面
有什么帮助吗?
提前致谢。
也许如果你像这样使用它就可以了
isReadOnly==true? true :false
这意味着如果 isReadOnly 为真 return 为真,否则 return 为假。
我有一个名为 isReadOnly
的标志,我使用以下语句从查询字符串参数中读取值。
this.isReadOnly = this.activatedRoute.snapshot.params['isReadOnly'];
我得到的值是正确的,但问题是在 html 中比较这个标志或它的否定没有按预期工作。
例如看下面的代码:
isReadOnly:{{isReadOnly}} -->if true
<br>
isReadOnly==false:{{isReadOnly==false}} --> returns false which is correct
但是
isReadOnly:{{isReadOnly}} --> if false
<br>
isReadOnly==false:{{isReadOnly==false}} --> returns false! its false == false, it should return true!
这发生在 IONIC 4 页面
有什么帮助吗?
提前致谢。
也许如果你像这样使用它就可以了
isReadOnly==true? true :false
这意味着如果 isReadOnly 为真 return 为真,否则 return 为假。