Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何根据angularjs中的模型条件隐藏和显示div?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想基于复选框隐藏/显示div.看起来很简单.我将复选框的值存储在模型中并在div ng-show中使用它.我究竟做错了什么?
<div ng-app='visibleApp'>
    <div ng-controller='myController'>
         <input type="checkBox" name="hideBasicInfo" ng-model="hideBasicInfo">hide the basic information section
         <div ng-show="{{!hideBasicInfo}}">
             <label for="firstName">First Name:</label>
             <input type="text" name="firstName" ng-model="firstName"/></br>

             <label for="middlename">Middle Name:</label>
             <input type="text" name="middlename" ng-model="middlename"/></br>
             <label for="lastName">last name:</label>
             <input type="text" name="lastName" ng-model="lastName"/>
         </div>
         <hr/>
         <div>
             <h4>Debug Information</h4>
             hideBasicInfo: {{hideBasicInfo}}<br/>
             !hideBasicInfo: {{!hideBasicInfo}}
         </div>
     </div>
</div>

JS档案:

var visibleApp = angular.module('visibleApp',[]);

visibleApp.controller('myController',function($scopE){
     $scope.data = "my data";
     $scope.hideBasicInfo = false; 
});

谢谢.

fiddle

@H_674_11@
@H_674_11@
差不多了…
<div ng-hide="hideBasicInfo">
    ...
 </div>

不需要模板括号({{}}).

@H_674_11@

大佬总结

以上是大佬教程为你收集整理的如何根据angularjs中的模型条件隐藏和显示div?全部内容,希望文章能够帮你解决如何根据angularjs中的模型条件隐藏和显示div?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。