1.要使用Bootstrap框架,必须在<head>中加入链接:

<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">

2.国内站点建议使用:

<link rel="stylesheet" href="//apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.min.css">

3.实例演示:

<!DOCTYPE html>

<html>

<link rel="stylesheet" href="http://apps.bding.com/libs/bootstrap/3.3.4/css/bootstrap/.min.js">

<script  src=http://apps.bding.com/libs/angular.js/1.4.6/angular.min.js></script>

<body ng-app="myApp" ng-controller="userCtrl">  //为<body>元素定义一个控制器

<div class="container">  //内容容器

<h3>User</h3>

<table class="table table-striped">  //带条纹背景的表格

  <thead><tr>

    <th>Edit</th>

    <th>First Name</th>

    <th>Last Name</th>

  </tr></thead>

  <tbody><tr ng-repeat="user in users">         //  循环users对象组,每个user对象放在<tr>元素中

    <td>

      <button class="btn" ng-click="editUser(user.id)">    //当点击<button>元素时调用函数editUser()

      <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;Edit         //字形图标,铅笔图标

      </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>Ctreate New User           //用户图标

</button>

<hr>

<h3 ng-show="edit">Create New User:</h3>   //如果edit=“true”显示<h3>元素

<h3 ng-hide="edit">Edit User:</h3>                //如果edit="true"隐藏<h3>元素

<form class="form-horizontal">       //水平表格

<div class="form-group">              //表单组

  <label class="col-sm-2 control-label">First Name:</label>    //控制器标签

  <div class="col-sm-10">

    <input type="text" ng-model="fName" ng-disabled="!edit" placeholder="First Name">   //为应用程序绑定<input>元素

  </div>

</div>

<div class="form-group">

  <label class="col-sm-2 control-label">Last Name:</label>     //跨越2列

  <div class="col-sm-10">               //跨越10列

    <input type="text" ng-model="lName" ng-disabled="!edit" placeholder="Last Name">

  </div>

</div>

<div class="form-group">

  <label class="col-sm-2 control-label">Password:</label>

  <div class="col-sm-10">

    <input type="password" ng-model="passw1" placeholder="Password">

  </div>

</div>

<div class="form-group">

  <label class="col-sm-2 control-label">Repeat:</label>

  <div class="col-sm-10">

    <input type="password" ng-model="passw2" placeholder="Repeat Password">

  </div>

</div>

</form>

<hr>

<button class="btn btn-success" ng-disabled="error || incomplete">    //如果发生错误或者ncomplete=true禁用<button>元素

  <span class="glyphicon glyphicon-save"></span>Save Changes

</button>

</div>

<script src="myUsers.js"></script>

</body>

</html>

4.Javascript代码:myUsers.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;

  }

};

});

Angular JS 学习之Bootstrap的更多相关文章

  1. 适合我胃口的angular.js学习资料

    断断续续弄了半年的ANGULAR.JS学习资料,网上下载了N多资料,测试了很多次. 现在只能算是入门,因时间问题,现在要转入其它领域. 如果以后要拾起来,下面这个PDF比较对我胃口. <Angu ...

  2. python , angular js 学习记录【1】

    1.日期格式化 Letter Date or Time Component Presentation Examples G Era designator Text AD y Year Year 199 ...

  3. Angular.js学习笔记 (二)

    用A链接对象解析url的组成 var url = 'https://www.baidu.com:8080/aaa/1.html?id=10#name'; var aLink = document.cr ...

  4. angular.js学习的第一天

    第一天对angular.js进行学习,肯定是面对的入门的最简单的实例: 实现下面的这个效果,首先需要在html页面引入angular.js,在下面的div中,ng-app则表示在当前div是一个ang ...

  5. Angular JS 学习之路由

    1.AngularJS路由允许我们通过不同的URL访问不同的内容:通过AngularJS可以实现多视图的单页WEB访问(SPA) 2.通常我们的URL形式为http://runoob.com/firs ...

  6. Angular JS学习之指令

    1.Angular JS通过称为指令的新属性来扩展HTML:通过内置的指令来为应用添加功能: 2.AngularJS指令:AngularJS指令是扩展的HTML属性,带有前缀ng-: **ng-app ...

  7. Angular JS学习之表达式

    1.Angular JS使用表达式把数据绑定到HTML: 2.Angular JS表达式写在双大括号中:{{expression}} **Angular JS表达式把数据绑定到HTML,这与ng-bi ...

  8. Angular JS 学习之简介

    1.Angular JS是一个JavaScript框架,它是一个以JavaScript编写的库,它可以通过<script>标签添加到HTML页面: <script src=" ...

  9. Angular JS 学习笔记(自定义服务:factory,Promise 模式异步请求查询:$http,过滤器用法filter,指令:directive)

    刚学没多久,作了一个小项目APP,微信企业号开发与微信服务号的开发,使用的是AngularJS开发,目前项目1.0版本已经完结,但是项目纯粹为了赶工,并没有发挥AngularJS的最大作用,这几天项目 ...

随机推荐

  1. usr/include/dispatch - dispatch_source

    博文一部分摘自:Parse分析,以下简称博文1(LeanCloud工程师针对Parse使用GCD的分析) 博文一部分摘自:GCD入门,以下简称博文2 建议先了解一下:BSD基础知识 在Dispatch ...

  2. <<< tomcat启动报错StandardServer.await: create[8005]

    启动tomcat的时候出现异常 严重: StandardServer.await: create[8005]: java.net.BindException: Address already in u ...

  3. Node.js入门笔记(2):全局对象(1)

    以下将以API文档为基础进行分析学习 global对象 这些对象在所有模块里都可用.有些对象不是在全局作用域而是在模块作用域里,这些情况下面文档都会标注出来. __filename--返回当前模块文件 ...

  4. Linux 命令收集

    http://www.cnblogs.com/tzhangofseu/archive/2011/12/17/2290955.html vim :r filename :sh  enter shell ...

  5. UVALive 4329 Ping pong

                                      Ping pong Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Fo ...

  6. UI设计

    微软压平的瓷砖设计符合最直接的信息接受方式,但不符合人类的审美观念. 换句话说,除了平,还有艺术,人类的脑力活动从不会平的像个白板,它是九曲十八弯的脉冲波动. 人类几千年的的审美史上,从没有出现过这种 ...

  7. 《C++ 101条建议》学习笔记——第一章快速入门

    1.C++程序组成:a.编译指示,由#开始,不由分号结束.只是影响编译过程.b.声明语句,影响编译过程,编译结果中并不会生成对应的指令.只是告诉编译器一些信息.c.可执行过程语句,生成对应的指令.包括 ...

  8. [codevs1105][COJ0183][NOIP2005]过河

    [codevs1105][COJ0183][NOIP2005]过河 试题描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子上.由于桥的长度和青 ...

  9. Proj.4坐标系统创建参数

    Proj.4坐标系统创建参数 本文由乌合之众lym瞎编,欢迎转载blog.cnblogs.net/oloroso 本文原文地址(https://github.com/OSGeo/proj.4/wiki ...

  10. 进度条ProgressDialog

    1.效果图 public void click(View view) { final ProgressDialog pdDialog = new ProgressDialog(this); //设置标 ...