鉴于这个使用 AngularJS 1.2 rc3 的测试用例:http: //plnkr.co/edit/MX6otx(下面重复)
1.
<li ng-init="toggle1 = false">
ng-if toggle1: {{ toggle1 }}
<p>
<button ng-if="!toggle1" ng-click="toggle1 = true">Turn On</button>
<button ng-if="toggle1" ng-click="toggle1 = false">Turn Off</button>
does not work
</li>
2.
<li ng-init="obj={toggle2:false}">
ng-if obj.toggle2: {{ obj.toggle2 }}
<p>
<button ng-if="!obj.toggle2" ng-click="obj.toggle2 = true">Turn On</button>
<button ng-if="obj.toggle2" ng-click="obj.toggle2 = false">Turn Off</button>
then why does this work?
</li>
问题:
- 为什么1不起作用?
- 1应该工作吗?
- 为什么 2 有效?
- 2应该工作吗?
- 我可以依靠 2 在 AngularJS 的未来更新中工作吗?