一句话: 大多数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. 20144303石宇森《网络对抗》注入shellcode和Return-to-libc攻击

    20144303石宇森<网络对抗>PC平台逆向破解 实验1:shellcode注入 实验基础 1.Linux下有两种基本构造攻击buf的方法:retaddr+nop+shellcode,n ...

  2. JRebel for IntelliJ 热部署破解方法

    1.打开idea,然后打开设置. 2.点击Plugins 3.重启之后点击 4.下载激活JRebel的插件,下载地址:https://github.com/ilanyu/ReverseProxy/re ...

  3. shell编程学习笔记之特殊变量($0、$1、$2、 $?、 $# 、$@、 $*)

    特殊变量($0.$1.$2. $?. $# .$@. $*) shell编程中有一些特殊的变量可以使用.这些变量在脚本中可以作为全局变量来使用. 名称 说明 $0 脚本名称 $1-9 脚本执行时的参数 ...

  4. 如何修改bootstrap模态框的backdrop蒙版区域的颜色?

    参考地址: http://www.cnblogs.com/9miao/p/4988196.html 蒙板样式实现: 大家或许注意到了,在做模态弹出窗时,底部常常会有一个透明的黑色蒙层效果:在Boots ...

  5. POJ 1260 Pearls (斜率DP)题解

    思路: 直接DP也能做,这里用斜率DP. dp[i] = min{ dp[j] + ( sum[i] - sum[j] + 10 )*pr[i]} ; k<j<i  =>  dp[j ...

  6. 【第二十五章】 springboot + hystrixdashboard

    注意: hystrix基本使用:第十九章 springboot + hystrix(1) hystrix计数原理:附6 hystrix metrics and monitor 一.hystrixdas ...

  7. 论文笔记——ThiNet: A Filter Level Pruning Method for Deep Neural Network Compreesion

    论文地址:https://arxiv.org/abs/1707.06342 主要思想 选择一个channel的子集,然后让通过样本以后得到的误差最小(最小二乘),将裁剪问题转换成了优化问题. 这篇论文 ...

  8. 事务(Transaction)

    1.演示转账的功能:(1)创建一张表示学生表表 CREATE TABLE student( id INT PRIMARY KEY AUTO_INCREMENT,name VARCHAR(50), ac ...

  9. The way to Go(6): Go程序的基本结构和要素

    Reference: Github: Go Github: The way to Go Go程序的基本结构和要素 helloworld.go: package main import "fm ...

  10. Ubuntu 14.04 下 OF-Config安装

    参考: Github of-config configure.ac - configure file issue OF-Config安装 1.安装OvS v2.3.1: Releases $ tar ...