我有一个div如下因素属性:ng-show="state.name === 'index'"。我也尝试过ng-show='state.name === "index",但仍然出现以下错误:
ng-show="state.name === 'index'"
ng-show='state.name === "index"
语法错误:令牌’ "index"‘是表达式的第16列的意外令牌,[state.name === "index"]始于["index"]。
"index"
[state.name === "index"]
["index"]
为什么?
我发现了问题。相反"state.name==='index'",我应该写"state.name=='index'"。pkoziowski.opensource是正确的,因为您不能使用条件语句,但是它们的含义是,您不能使用if语句或与此相关的任何控制流语句,因此您不能这样做:
"state.name==='index'"
"state.name=='index'"
<span ng-init="if(state.name == 'o'){doFoo();}">o</span>