[乐意黎转载]AngularJS快速入门指南16:Bootstrap
发布时间:2020-12-17 09:34:57 所属栏目:安全 来源:网络整理
导读:Bootstrap是一套非常流行的样式表框架,本章用以演示如何在AngularJS中使用它。 Bootstrap 为了在AngularJS application中使用Bootstrap,你需要将下面这行代码加入到页面的head部分(或者去Bootstrap官网下载包然后引用到页面上): link rel ="stylesheet"
Bootstrap是一套非常流行的样式表框架,本章用以演示如何在AngularJS中使用它。 Bootstrap为了在AngularJS application中使用Bootstrap,你需要将下面这行代码加入到页面的head部分(或者去Bootstrap官网下载包然后引用到页面上): <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> 查看Bootstrap中文官网以了解更多有关http://www.bootcss.com/ 下面是一个完整的HTML示例,并附有AngularJS指令和Bootstrap类的说明。 HTML代码 <!DOCTYPE html> htmlscript src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></scriptbody ng-app="myApp" ng-controller="userCtrl"> div class="container"h3>Users</table ="table table-striped"> thead><tr> th>Edit>First Name>Last Nametbodytr ng-repeat="user in users"td> button ="btn" ng-click="editUser(user.id)"span ="glyphicon glyphicon-pencil"span> Edit button>{{ user.fName }}>{{ user.lName }}tablehr="btn btn-success"="editUser('new')"="glyphicon glyphicon-user"> Create New User h3 ng-show="edit">Create New User:ng-hide>Edit User:form ="form-horizontal"="form-group"label ="col-sm-2 control-label">First Name:label="col-sm-10"input type="text" ng-model="fName" ng-disabled="!edit" placeholder="First Name"div> >Last Name:="lName"="Last Name">Password:="password"="passw1"="Password">Repeat:="passw2"="Repeat Password"form="error || incomplete"="glyphicon glyphicon-save"> Save Changes src = "myUsers.js"body> 运行 上例中出现的AngularJS指令解释
Bootstrap类解释
JavaScript代码 angular.module('myApp',[]).controller('userCtrl',function($scope) { $scope.fName = ''; $scope.lName = ''; $scope.passw1 = ''; $scope.passw2 = ''; $scope.users = [ {id:1,fName:'Hege',lName:"Pege" },{id:2,fName:'Kim',lName:"Pim" },{id:3,fName:'Sal',lName:"Smith" },{id:4,fName:'Jack',lName:"Jones" },{id:5,fName:'John',lName:"Doe" },{id:6,fName:'Peter',lName:"Pan" } ]; $scope.edit = true; $scope.error = false; $scope.incomplete = false; $scope.editUser = function(id) { if (id == 'new') { $scope.edit = true; $scope.incomplete = true; $scope.fName = ''; $scope.lName = ''; } else { $scope.edit = false; $scope.fName = $scope.users[id-1].fName; $scope.lName = $scope.users[id-1].lName; } }; $scope.$watch('passw1',255); line-height:1.5!important">function() {$scope.test();}); $scope.$watch('passw2',255); line-height:1.5!important">function() {$scope.test();}); $scope.$watch('fName',255); line-height:1.5!important">function() {$scope.test();}); $scope.$watch('lName',255); line-height:1.5!important">function() {$scope.test();}); $scope.test = function() { if ($scope.passw1 !== $scope.passw2) { $scope.error = true; } else { $scope.error = false; } $scope.incomplete = false; if ($scope.edit && (!$scope.fName.length || !$scope.lName.length || !$scope.passw1.length || !$scope.passw2.length)) { $scope.incomplete = true; } }; }); JavaScript代码解释
本文转载自:http://www.cnblogs.com/jaxu/p/4504923.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- angularjs – 使用Angular ui-router设置无状态更改的URL查
- WebService调用天气接口例子
- 【0610】【数据结构】【C语言版视频教程】【 全52讲 完整版
- vbscript – WScript.Shell.Exec – 从stdout读取输出
- angular – 为动态创建的输入添加/删除反应式表单验证器
- angular – Alias已被“–collection”选项使用,不能被“–
- 视口设置为user-scalable = no时,iOS / mobile safari仍然放
- WinForm调用WebService简单实例详解【新手入门】
- 事件 – 跟踪滚动位置并通知其他组件(Angular2)
- WebService返回DataSet,Xml,Json