<ng-switch on="MyData.Status">
<p ng-switch-when="2">
<p ng-if="MyData.SomeProp == false">
Message 1
</p>
<p ng-if="MyData.SomeProp == true">
Message 2
</p>
</p>
</ng-switch>
我想仅在ng-switch-when =“2时执行MyData.SomeProp == false
代码块。
伪代码将是
if (MyData.Status == 2){
if (MyData.SomeProp == false){
print message 1
}
else{
print message 2
}
}
如何使用angularjs
执行此简单语句答案 0 :(得分:4)
使用ng-show
代替ng-if
:
<ng-switch on="MyData.Status">
<p ng-switch-when="2">
<p ng-show="MyData.SomeProp == false">
Message 1
</p>
<p ng-show="MyData.SomeProp == true">
Message 2
</p>
</p>
</ng-switch>