AngularJS Bootstrap
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了AngularJS Bootstrap,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4077字,纯文字阅读大概需要6分钟。
内容图文
AngularJS 的首选样式表是 Twitter Bootstrap, Twitter Bootstrap 是目前最受欢迎的前端框架。
Bootstrap
你可以在你的 AngularJS 应用中加入 Twitter Bootstrap,你可以在你的 <head>元素中添加如下代码:
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
如果站点在国内,建议使用百度静态资源库的Bootstrap,代码如下:
<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">
以下是一个完整的 HTML 实例, 使用了 AngularJS 指令和 Bootstrap 类。
<! DOCTYPE html > < html > < head > < meta charset ="utf-8" > < link rel ="stylesheet" href ="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css" > < script src ="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js" ></ script > </ head > < body ng-app ="myApp" ng-controller ="userCtrl" > < div class ="container" > < h3 >Users</h3><table class="table table-striped"><thead><tr><th>编辑</th><th>名</th><th>姓</th></tr></thead><tbody><tr ng-repeat="user in users"><td><button class="btn" ng-click="editUser(user.id)"><span class="glyphicon glyphicon-pencil"></span>编辑 </button></td><td>{{ user.fName }}</td><td>{{ user.lName }}</td></tr></tbody></table><hr><button class="btn btn-success" ng-click="editUser(‘new‘)"><span class="glyphicon glyphicon-user"></span>创建新用户 </button><hr><h3 ng-show="edit">创建新用户:</h3><h3 ng-hide="edit">编辑用户:</h3><form class="form-horizontal"><div class="form-group"><label class="col-sm-2 control-label">名:</label><div class="col-sm-10"><input type="text" ng-model="fName" ng-disabled="!edit" placeholder="名"></div></div><div class="form-group"><label class="col-sm-2 control-label">姓:</label><div class="col-sm-10"><input type="text" ng-model="lName" ng-disabled="!edit" placeholder="姓"></div></div><div class="form-group"><label class="col-sm-2 control-label">密码:</label><div class="col-sm-10"><input type="password" ng-model="passw1" placeholder="密码"></div></div><div class="form-group"><label class="col-sm-2 control-label">重复密码:</label><div class="col-sm-10"><input type="password" ng-model="passw2" placeholder="重复密码"></div></div></form><hr><button class="btn btn-success" ng-disabled="error || incomplete"><span class="glyphicon glyphicon-save"></span>修改 </button></div><script src="js/myUser.js"></script></body></html>
myUser.js
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‘, function() { $scope.test(); }); $scope.$watch(‘passw2‘, function() { $scope.test(); }); $scope.$watch(‘fName‘, function() { $scope.test(); }); $scope.$watch(‘lName‘, 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; } }; })
原文:http://www.cnblogs.com/chrisghb8812/p/5674283.html
内容总结
以上是互联网集市为您收集整理的AngularJS Bootstrap全部内容,希望文章能够帮你解决AngularJS Bootstrap所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。