angular+bootstrap的双向数据绑定实例
编程学习 2021-07-04 19:20www.dzhlxh.cn编程入门
本篇文章主要介绍angular+bootstrap的双向数据绑定的实例,具有很好的参考价值。狼蚁网站SEO优化跟着长沙网络推广一起来看下吧
效果图:
代码如下:
<!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>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持狼蚁SEO!