一句话: 大多数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. Android http通信案例

    Android studio 编写安卓程序,实现 http 通信,获得百度主页源代码. -------------------------------------------------------- ...

  2. linux下如何查看当前机器提供了哪些服务

    答:使用netstat工具 在命令行下输入netstat -atun即可列出当前机器提供的服务 netstat各选项解析: -a 列出所有服务 -t 列出tcp相关 -u 列出udp相关 -n 以数字 ...

  3. HDU1556 Color the ball(差分数组)题解

    Color the ball Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

  4. 论文笔记:Mastering the game of Go with deep neural networks and tree search

    Mastering the game of Go with deep neural networks and tree search Nature 2015  这是本人论文笔记系列第二篇 Nature ...

  5. 网络量化——Quantized Convolutional Neural Networks for Mobile Devices

    论文地址:https://arxiv.org/abs/1512.06473 源码地址:https://github.com/jiaxiang-wu/quantized-cnn 1. 主要思想 这篇文章 ...

  6. 关于使用jquery的Ajax结合java的Servlet后台判定用户名是否存在

    关于把AJAX加入到注册登录demo中去 2018年3月10日 19:21:23 第一次来SUBWAY真切地打代码. 这次的西红柿汤还是挺好喝的. index.jsp: <%@ page con ...

  7. org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement profile

    原创:转载请注明出处 1.异常情况 org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected ...

  8. js中一些关于比较左右两边的值的题目

    alert(typeof(NaN)); alert(typeof(Infinity)); alert(typeof(null)); alert(typeof(undefined)); alert(Na ...

  9. 《Robot Framework自动化测试修炼宝典》道长

    1. Python下载https://www.python.org/downloads 2. Setuptools下载https://pypi.python.org/pypi/setuptools用原 ...

  10. mysql 超大数据/表管理技巧

    如果你对长篇大论没有兴趣,也可以直接看看结果,或许你对结果感兴趣.在实际应用中经过存储.优化可以做到在超过9千万数据中的查询响应速度控制在1到20毫秒.看上去是个不错的成绩,不过优化这条路没有终点,当 ...