angular+bootstrap的双向数据绑定实例
程序员文章站
2022-04-29 09:00:33
效果图:
代码如下:
效果图:
代码如下:
<!doctype html> <html ng-app="userinfomodule"> <head> <meta charset="utf-8"> <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="external nofollow" > <script src="js/angular-1.3.0.js"></script> </head> <body> <div> <div class="panel panel-primary"> <div class="panel-heading"> <div class="panel-title"> 双向数据绑定 </div> </div> <div class="panel-body"> <div class="row"> <div class="col-md-12"> <form class="form-horizontal" role="form" ng-controller="userinfoctrl"> <div class="form-group"> <label class="col-md-2 control-label">邮箱:</label> <div class="col-md-10"> <input type="email" class="form-control" placeholder="推荐使用126邮箱" ng-model="userinfo.email"> </div> </div> <div class="form-group"> <label class="col-md-2 control-label">密码:</label> <div class="col-md-10"> <input type="password" class="form-control" placeholder="只能是数字、字母、下划线" ng-model="userinfo.password"> </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <div class="checkbox"> <label> <input type="checkbox" ng-model="userinfo.autologin">自动登录 </label> </div> </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <button class="btn btn-default" ng-click="getformdata()"> 登录 </button> </div> </div> </form> </div> </div> </div> </div> </div> </body> <script> var userinfomodule = angular.module('userinfomodule',[]); userinfomodule.controller('userinfoctrl',['$scope',function($scope){ $scope.userinfo={ email:'1101867009@qq.com', password:'xu201133016', autologin:true }; $scope.getformdata=function(){ $scope.userinfo={ email:'1101867009@qq.com', password:'xu201133016', autologin:true }; }; $scope.setformdata=function(){ $scope.userinfo={ email:'xu13071061935@163.com', password:'xu201133016', autologin:false } }; }]) </script> </html>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!
上一篇: tez hive llap安装