ng-show 不适用于布尔值
ng-show is not working with boolean values
我正在尝试将几个div与服务值绑定"
<body ng-controller="PageConfigurationController">
<label>{{TopLeftPage}}</label><label>{{TopRightPage}}</label>
<label>{{ButtomRightPage}}</label><label>{{ButtomLeftPage}}</label>
<div ng-show="{{TopLeftPage}}"><h1>Div1 </h1></div>
<div ng-show="{{TopRightPage}}"><h1>Div2 </h1></div>
<div ng-show="{{ButtomRightPage}}"><h1>Div3 </h1></div>
<div ng-show="{{ButtomLeftPage}}"><h1>Div4 </h1></div>
标签很好地显示了布尔值,但默认情况下,所有div 都被隐藏,无论它是真的还是假的。
<div ng-show="TopLeftPage"><h1>Div1 </h1></div>
<div ng-show="TopRightPage"><h1>Div2 </h1></div>
<div ng-show="ButtomRightPage"><h1>Div3 </h1></div>
<div ng-show="ButtomLeftPage"><h1>Div4 </h1></div>
从 ng-show 和 js 中删除大括号
$scope.TopLeftPage=true;
$scope.TopRightPage=true;
$scope.ButtomRightPage=true;
$scope.ButtomLeftPage=true;
为真表示显示,假表示隐藏
可以直接在 ng-show 中使用表达式
<div ng-show="TopLeftPage"><h1>Div1 </h1></div>
<div ng-show="TopRightPage"><h1>Div2 </h1></div>
<div ng-show="ButtomRightPage"><h1>Div3 </h1></div>
<div ng-show="ButtomLeftPage"><h1>Div4 </h1></div>
并确保表达式的值应该是真或假布尔值而不是字符串
相关文章:
- JQueryhide()不适用于Mozzilla,但适用于Chrome
- PHP中的setcookie仅适用于localhost
- 如何从javascript/jquery中的复选框中获取布尔值
- html5 drawImage适用于firefox,而不是chrome
- KendoUI网格行过滤器,带有布尔值下拉列表
- 提供“;onClick"适用于iPad(触摸屏)和桌面用户的默认功能
- jQuery表单验证适用于Mozilla和Internet Explorer,但不适用于Chrome或Safari
- php布尔值's小写AND大写和数字布尔值'可以接受
- getter和setter只适用于ES5中的基元值吗
- ng-show 不适用于布尔值
- !!Sytactic Sugar,用于检查JavaScript中未定义的布尔值
- 未在火狐浏览器的选择列表中选择值(适用于chrome,safari,opera)
- 日期选取器将今天的日期显示为默认值,并且仅适用于 GET
- 如何设置适用于HTML5浏览器和旧浏览器的type=date输入的默认值
- 为什么我的localStorage复选框/布尔值比较不适用于我的Google Chrome扩展
- JavaScript后缀了一个用于限制事件的布尔值/一次性标志
- onclickjavascript不再适用于_GET.php表单值
- 如何发送文件以接收返回值(适用于InternetExplorer8-9)
- Mongoose findByIdAndUpdate 方法,用于切换和更新数据库中的布尔值
- 将布尔值从 rails 控制器传递到 javascript 以用于条件