发现了一个 Angularjs ng-show ng-if 的错误
found a bug for angularjs ng-show ng-if?
我发现了angularjs的几个错误:
<div ng-show="['[]']">this should be show but actually not</div>
<div ng-show="[]">this should be show but actually not</div>
<div ng-show="[0]">this should be show but actually not</div>
<div ng-show="['0']">this should be show but actually not</div>
当这些条件在 JavaScript 的 if
语句中使用时,它们被视为 true。但是在ng-show
、ng-hide
、ng-if
中,它不能正常工作。
这是一个错误吗?
上述所有语句都是无效语句。我给你举个例子。
//What you have done here is created an array with a string of '[]' which has no expression to return true or false;
<div ng-show="['[]']">this should be show but actually not</div>
// Here is just an empty array again with no expression to return true or false. Better use would be myArray.length > 0 which will evaluate as true or false;
<div ng-show="[]">this should be show but actually not</div>
//Here is just like the first one except you have an array of one number being 0 which will still never evaluate to a true or false;
<div ng-show="[0]">this should be show but actually not</div>
//I dont think this one needs any explaining as you can see the pattern from above;
<div ng-show="['0']">this should be show but actually not</div>
您没有正确使用 ng-show/if。你总是需要一个可以计算真或假的表达式,或者一个将返回真或假的函数。不要将 html 中的角度等同于你的 JavaScript。
相关文章:
- 使用angularjs ng Show/ng hide显示和隐藏不同的内容
- 如何在AngularJS视图中使用promise(ng-show)
- AngularJS:如何使用java脚本函数更改跨度的ng-show条件
- AngularJS:使用ng-show/hide动态维护下拉列表的3种状态(InProgress、Success、Err
- AngularJS:ng-show不适用于ng-app
- AngularJS:为什么ng show没有在IE11上运行
- Angularjs ng-show not working with checkbox with default val
- Angularjs - grouping ng show
- AngularJS:隐藏<td>使用ng-hide/ng-show没有间隙
- Angularjs ng-show == Id?
- 使用 class、ng-show 和 ng-class 执行 AngularJS 动画
- AngularJS ng-click不显示ng-show消息
- AngularJs 过渡水平菜单与 ng-show
- ng-show on AngularJS alert
- AngularJS在使用ng-show ng-hide时,我仍然看到这两个对象1ms
- AngularJS:字体真棒喜欢按钮未显示在ng-show下
- AngularJS ng-hide / ng-show
- 发现了一个 Angularjs ng-show ng-if 的错误
- ng-hide & ng-show in AngularJS
- AngularJS - ng-show 在对象加载时显示内容