我是 AngularJS 的新手,所以我的问题可能有一个简单的解决方案。我一直在处理这个表格。我有两个输入 - 一个是门的数量,一个是窗户的数量。然后,如果它们满足一定数量的门窗总数,我想显示几个 div。当我在输入中输入数字时,ng-show 解析为“true”。但是该元素仍然具有“ng-hide”类,它仍然隐藏。
这是我的代码示例:
<body ng-app>
Doors: <input type="number" ng-model="doors"><br>
Windows: <input type="number" ng-model="windows"><br>
<div ng-show="{{(doors + windows) < 6}}">
Shows if you have 0-5 doors and windows combined.
</div>
<div ng-show="{{(doors + windows) > 5 && (doors + windows) < 11}}">
Shows if you have 6-10 doors and windows combined.
</div>
<div ng-show="{{(doors + windows) > 10 }}">
Shows if you have more than 10 doors and windows combined.
</div>
</body>
这是我进入 3 个门和 4 个窗口时的输出:
<div ng-show="false" class="ng-hide">
Shows if you have 0-5 doors and windows combined.
</div>
<div ng-show="true" class="ng-hide">
Shows if you have 6-10 doors and windows combined.
</div>
<div ng-show="false" class="ng-hide">
Shows if you have more than 10 doors and windows combined.
</div>