一句话: 大多数html标签属性和事件都有一个对应的ng指令

说明:这些指令和原生html最大的区别就是可以动态更新.比如一个div的样式用ng-class后,我们就可以随意应用css class.

1. 内置指令大全

ng-include 包含一个文件
ng-href ng-src 对应 href src
ng-disabled ng-readonly 对应 disabled readonly
ng-checked ng-selected ng-options ng-true-value ng-false-value 对应 checked select option
ng-class ng-style ng-class-even ng-class-odd ng-show ng-hide ng-cloak class style, 隔行用不同样式, 元素显示与否, 加载不完全时闪烁效果
ng-switch ng-if ng-repeat ng-repeat-start ng-repeat-end 逻辑控制 元素生成与否与遍历元素
ng-submit ng-click ng-dblclick ng-change ng-mousedown ng-mouseenter ng-mouseleave ng-mousemove ng-mouseover ng-mouseup 相应的鼠标键盘事件
ng-bind ng-bind-html ng-bind-html-unsafe ng-bind-template 绑定显示数据: 文本,半html,全html,组合模板
ng-view ng-route 路由功能

2.  运行结果(所有标签都有相应实例)

url: http://jimuyouyou.github.io/angular-bootstrap-rest-seed/examples/angular/3-ng-directives.html

3. 源码

 <div>
<span ng-init="global.trueval='hello'"></span>
<span ng-init="global.falseval=false"></span>
<span ng-init="global.array=['dog', 'goat', 'cat']"></span>
<span ng-init="global.objArray=[{name: 'dog', age: 10}, {name: 'goat', age: 20}, {name: 'cat', age: 30}]"></span> <hr>
<div>
<label>ng-include实例-有的浏览器可能不支持</label>
<div ng-include="'partials/ng-include.html'"></div> <span ng-init="ni.tempalteName='partials/ng-include-var.html'"></span>
<div ng-include="ni.tempalteName"></div>
</div> <hr>
<div>
<p></p>
<label>ng-href ng-src实例</label><p></p>
<span ng-init="nh.baidu='www.baidu.com'"></span>
<a ng-href="http://{{nh.baidu}}">ng-href百度</a><br>
<img ng-src="https://www.baidu.com/img/bd_logo1.png" style="width:60px;height:20px" />ng-src
</div> <hr>
<div><p></p>
<label>ng-disabled ng-readonly实例</label><p></p>
<button ng-disabled="global.trueval">ng-disabled</button>
<input type="text" ng-readonly="global.trueval" placeholder="ng-readonly">
</div> <hr>
<div><p></p>
<label>ng-checked ng-selected ng-options ng-true-value ng-false-value实例</label><p></p>
<input type="checkbox" ng-checked="global.trueval" ng-true-value="admin" ng-false-value="basic"> ng-checked ng-true-value="admin" ng-false-value="basic" <p></p>
<select ng-model='test.name' ng-options="elem.value as elem.name for elem in global.objArray">
<option>--</option>
</select>ng-options <select>
<option>--</option>
<option ng-repeat="elem in global.objArray" value="{{elem.name}}" ng-selected="elem.name=='dog'">
{{elem.age}}
</option>
</select>ng-selected </div> <hr>
<div><p></p>
<label>ng-class ng-style ng-class-even ng-class-odd ng-show ng-hide ng-cloak实例</label><p></p>
<input type="text" ng-class="{'btn-success' : global.trueval, 'btn': global.falseval}" ng-style="{width: '300px', height: '30px'}"> ng-class ng-style <p></p>
<table>
<tr ng-repeat="elem in global.objArray" ng-class-even="'bg-success'" ng-class-odd="'bg-danger'"><td>{{elem.name}} ng-class-even ng-class-odd</td></tr>
</table>
<input type="button" ng-show="global.trueval" class="btn btn-success" value="ng-show">
<input type="button" ng-hide="!global.trueval" class="btn btn-primary" value="ng-hide">
<p ng-cloak>ng-cloak </p>
</div> <hr>
<div><p></p>
<label>ng-switch ng-if ng-repeat ng-repeat-start ng-repeat-end实例</label><p></p>
<div ng-switch on="global.trueval">
<div ng-switch-when="abc">ng-switch-when abc</div>
<div ng-switch-default>ng-switch-default</div>
</div>
<div ng-if="global.trueval">ng-if</div> <ul>
<li ng-repeat-start="elem in global.objArray">
<strong>{{elem.name}}</strong>
</li>
<li ng-repeat-end>{{elem.age}}</li>
</ul>ng-repeat-start ng-repeat-end: 从start标记的元素开始,到end标记的元素结束,作为循环体进行循环输出,可以跳出父子元素关系。
</div> <hr>
<div><p></p>
<label>ng-submit ng-click ng-dblclick ng-change ng-mousedown ng-mouseenter ng-mouseleave ng-mousemove ng-mouseover ng-mouseup实例</label>
<div ng-controller="EventsController">
<span class="bg-danger">{{currentEventName}}</span><p></p>
<button ng-click="ngEvents('ng-click')">ng-click</button>
<span ng-dblclick="ngEvents('ng-dblclick')">ng-dblclick</span>
<input ng-model="currentEventName" type="text" ng-change="ngEvents('ng-change')" placehodler"ng-change me"><p></p>
<span ng-mousedown="ngEvents('ng-mousedow')" ng-mouseenter="ngEvents('ng-mousedow')" ng-mouseleave="ngEvents('ng-mouseleave')" ng-mousemove="ngEvents('ng-mousemove')" ng-mouseover="ngEvents('ng-mouseover')" ng-mouseup="ngEvents('ng-mouseup')" >ng-mousedown ng-mouseenter ng-mouseleave ng-mousemove ng-mouseover ng-mouseup</span>
</div> <script>
var myApp = angular.module('myApp', []);
myApp.controller('EventsController', function($scope) {
$scope.ngEvents = function(param1) {
$scope.currentEventName = param1;
}
});
</script>
</div> <hr>
<div ng-controller="BindController"><p></p>
<label>ng-bind ng-bind-html ng-bind-html-unsafe ng-bind-template实例</label><p></p>
<span ng-bind="nb.textval"></span> ng-bind <p></p>
<span ng-bind-template="{{ nb.textval }} and ng-bind-template {{ nb.htmlval }}"></span> ng-bind-template <p></p>
ng-bind-html ng-bind-html-unsafe需要引入sanitize文件,也就是说Angular不推荐html <script>
myApp.controller('BindController', function($scope, $sce) {
$scope.nb = {};
$scope.nb.textval = 'I am a text';
$scope.nb.htmlval = $sce.trustAsHtml('I am a html<strong>strong</strong> content');
});
</script>
</div> <hr>
<div><p></p>
<label>ng-view ng-route实例</label><p></p>
url: <a href="http://jimuyouyou.github.io/SearchableCookbook4Coder/plugins/angular-js/ng-view-ngRoute.html">http://jimuyouyou.github.io/SearchableCookbook4Coder/plugins/angular-js/ng-view-ngRoute.html</a>
</div>
<hr><hr> </div>

4. 项目地址

github: https://github.com/jimuyouyou/angular-bootstrap-rest-seed

简话Angular 03 Angular内置表达式大全的更多相关文章

  1. React入门---JSX内置表达式-6

    个人理解:接触的JSX就是在React中render方法里面的js,因为里面只能有一个节点,所以你写的东西都在一个div中,要有js所以通过JSX来表达.(个人菜鸟理解,欢迎指正) React 使用 ...

  2. mysql 内置函数大全 mysql内置函数大全

    mysql 内置函数大全 2013年01月15日 19:02:03 阅读数:4698 对于针对字符串位置的操作,第一个位置被标记为1. ASCII(str) 返回字符串str的最左面字符的ASCII代 ...

  3. Orace内置函数大全[转:http://www.cnblogs.com/lfx0692/articles/2395950.html]

    NewProgramer   Oracle SQL 内置函数大全(转) SQL中的单记录函数 1.ASCII 返回与指定的字符对应的十进制数;SQL> select ascii('A') A,a ...

  4. python3内置函数大全(顺序排列)

    python3内置函数大全 内置函数 (1)abs(),   绝对值或复数的模 1 print(abs(-6))#>>>>6 (2)all() 接受一个迭代器,如果迭代器的所有 ...

  5. python内置函数大全(分类)

    python内置函数大全 python内建函数 最近一直在看python的document,打算在基础方面重点看一下python的keyword.Build-in Function.Build-in ...

  6. [转] Angular 4.0 内置指令全攻略

    [From] https://segmentfault.com/a/1190000010416792 简书链接 在这篇文章中,我们将分别列举每一个内置指令的用法,并提供一个例子作为演示.尽量用最少最简 ...

  7. Angular中的内置指令和自定义指令

    NG中的指令,到底是什么(what)? 为什么会有(why)?以及怎样使用(how)? What: 在NG中,指令扩展HTML功能,为 DOM 元素调用方法.定义行为绑定数据等. Why: 最大程度减 ...

  8. Python补充03 Python内置函数清单

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明. Python内置(built-in)函数随着python解释器的运行而创建.在Pytho ...

  9. python exec内置表达式--exec()

    exec obj功能: exec 执行储存在字符串或文件中的Python语句,相比于 eval,exec可以执行更复杂的 Python 代码.obj 是 要执行的表达式.exec 返回值永远为 Non ...

随机推荐

  1. Python3 itchat实现微信定时发送群消息

    Python3 itchat实现微信定时发送群消息 一.简介 1,使用微信,定时往指定的微信群里发送指定信息. 2,需要发送的内容使用excel进行维护,指定要发送的微信群名.时间.内容. 二.py库 ...

  2. spring mybatis 3.2调用mysql存储过程返回多结果集(完整、亲测、可用)

    最近,有个开发提了个需求,希望中间件支持调用mysql存储过程时支持多结果集返回,因为某些原因我们使用了不少的存储过程,很多复杂的逻辑目前来看交互非常的多,所以从当前的现状来说,这个需求还是蛮合理的. ...

  3. linux下递归列出目录下的所有文件名(不包括目录)

    1.linux下递归列出目录下的所有文件名(不包括目录) ls -lR |grep -v ^d|awk '{print $9}'2.linux下递归列出目录下的所有文件名(不包括目录),并且去掉空行 ...

  4. 使用Android-studio开发移动app与weex结合开发详细步骤

    详细步骤如下:   首先,确保机器已经安装了node.js,并且把npm更新到最新版本 下载完毕后,我们可以看到全局目录下的node_modules下面多出一个weex-toolkit 同时,我们留意 ...

  5. C# 如何调用启动窗体

    Program.cs中代码如下: using System; using System.Collections.Generic; using System.Windows.Forms; namespa ...

  6. UVa 10801 电梯换乘

    https://vjudge.net/problem/UVA-10801 题意:有多个电梯,每个电梯只能到达指定楼层,每个电梯有速度,如果中途换乘电梯,需要额外加60s,求从0层到达k层的最少时间. ...

  7. IEnumerable与IEnumerator

    IEnumerable接口 IEnumerable接口:实现该接口的类,表明该类下有可以枚举的元素 public interface IEnumerable { //返回一个实现了IEnumerato ...

  8. ubuntu 14.04 安装redis5.0.3

    redis下载地址:http://download.redis.io/releases/ 新建Redis目录,下载Redis 安装包: mkdir rediscd rediswget http://d ...

  9. python ros 关闭节点

    def myhook(): print "shutdown time!" rospy.on_shutdown(myhook) 或 rospy.signal_shutdown(rea ...

  10. python 压缩tar 包

    import tarfile import os def make_targz(output_filename, source_dir): print("doing!") with ...