秒味课堂Angular js笔记------指令
1.属性指令
- angularjs样式相关指令:
- ng-class
- ng-style
- ng-href
- ng-src
- ng-attr-(suffix)
- ng-bind
- ng-cloak 没解析完之前标签是隐藏的,解析完后标签是显示的,控制css的指令
- ng-bind-template 支持多表达式'{{text}},{{text}}'
- ng-bind-html 解析字符串中的标签,需要依赖angular-sanitize.min.js
- ng-non-bindable 不解析表达式,就原样输出{{text}}
- ng-show
- ng-hide
- ng-if 当表达式为true ,该标签显示。并不是通过css操作,而且dom的添加删除的操作。
- ng-switch
- on
- default
- when
<div ng-switch on="bBtn">
<p ng-switch-default>默认的效果</p>
<p ng-switch-when = "false">切换的效果</p>
</div>
- ng-open 针对details标签,有兼容性,只支持chrome和Safari
<details ng-open="true"> //true显示下面列表,false不显示
<summary>Copyright 2011.</summary>
<p>All pages and graphics on this web site are the property of W3School.</p>
</details>
- ng-init 建议在循环嵌套中利用此指令定义初始循环变量
<div ng-controller = "Ctr" ng-init = "aIndex = $index ">
{{aIndex}}
</div>
- ng-include 引入模板
- ng-model 扩展,可以对数据添加条件,比如光标离开时更新数据。
<script type="application/javascript">
var sStyle = angular.module("sStyle",[]);
sStyle.controller("styleController",["$scope",function($scope){
$scope.text = "hello";
}])
</script>
<body>
<div ng-controller = "styleController">
<input type="input" ng-model="text" ng-model-options="{updateOn : 'blur'}"/>
<div>{{text}}</div>
</div>
</body>
- ng-controller
- as 针对面向对象
2.标签指令,用于表单验证中
- <a> 在ng-app中会阻止默认行为
- <select> <script type="application/javascript"> var sStyle = angular.module("sStyle",[]);
<script type="application/javascript">
var sStyle = angular.module("sStyle",[]);
sStyle.controller("styleController",["$scope",function($scope){
$scope.colors=[
{ name : "red"},
{ name : "yellow"},
{ name : "blue"}
];
}])
</script>
<body>
<div ng-controller = "styleController">
<a href ="">{{myColor.name}}</a>
<select ng-options = "color.name for color in colors" ng-model = "myColor">
</select>
</div>
</body>
- <textarea>
- <input>
- <form>
- novalidate 阻止html5表单自带的样式,比如没有按照type="email"格式输入,鼠标点击其他位置,此时边框会默认变红色。
3.表单验证
- $valid 表单验证成功返回true,验证失败返回false
- $invalid 相反
- $pristine 表单验证的值未修改返回true,修改过返回false
- $dirty 相反
- $error 验证失败
支持表单验证
- type
- number
- url
- required
秒味课堂Angular js笔记------指令的更多相关文章
- 秒味课堂Angular js笔记------Angular js中的工具方法
Angular js中的工具方法 angular.isArray angular.isDate angular.isDefined angular.isUndefined angular.isFunc ...
- 秒味课堂Angular js笔记------过滤器
不同过滤器的小demo. currency number uppercase json limitTo date orderBy filter <script> var filterMy ...
- 秒味课堂Angular js笔记------$scope.$watch和$scope.$apply
$scope.$watch(watchFn , watchAction , deepWatch) 其中,watchFn是带有angular表达式或函数字符串: watchAction是一个函数或者表达 ...
- Angular.js之指令学习笔记
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"& ...
- Angular JS笔记
1.引导程序 使用ng-app开始引导一个程序:标记了AngularJS应用的作用域 <!doctype html> <html lang="en" ng-app ...
- Angular JS 中 指令详解
Angular JS的强大功能就在于其可以自定义很多指令,现在就指令做一下详细的剖析. 一个Angular js 指令(directive)需要指定一个唯一的名字(myDirective)和一个函数, ...
- Angular JS - 7 - Angular JS 常用指令2
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- Angular JS - 6 - Angular JS 常用指令
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- angular js 自定义指令
我们有些时候需要把后台返回过来的带有html标签的字符串binding到界面中一个指定的div或者其他的控制器中. 使用普通ng-bind不会自动解析出html语句. js中这样定义: app.dir ...
随机推荐
- 利用Php ssh2扩展实现svn自动提交到测试服务器
1.安装ssh2扩展 (1)window . 下载 php extension ssh2 下载地址 http://windows.php.net/downloads/pecl/releases/ssh ...
- eval函数
eval()函数中的eval是evaluate的简称,这个函数的作用就是把一段字符串当作PHP语句来执行 <?php $a=100;eval("echo $a;"); ...
- Python报错:SyntaxError: Non-ASCII character '\xe5' in file的解决方法
SyntaxError: Non-ASCII character '\xe5' in file 原因:Python默认是以ASCII作为编码方式的,如果在自己的Python源码中包含了中文(或者其他的 ...
- iOS开发——OC篇&纯代码退出键盘
关于iOS开发中键盘的退出,其实方法有很多中,而且笔者也也学会了不少,包括各种非纯代码界面的退出. 但是最近开始着手项目的时候却闷了,因为太多了,笔者确实知道有很多中方法能实现,而且令我影响最深的就是 ...
- Unity扩展编辑器--类型1:Editor Windows
Extending the Editor Unity允许你使用自己定制的inspectors和Editor Windows扩展编辑器,并且你可以使用定制的Property Drawers定义属性集在i ...
- readn、write、readline
字节流套接字上的read和write函数所表现的行为不同于通常的文件IO 字节流套接字上调用read或write输入或输出的字节数可能比请求的数量少,然而这不是出错的状态 这个现象的原因在于内核中用于 ...
- poj A Round Peg in a Ground Hole
http://poj.org/problem?id=1584 #include<cstdio> #include<cstring> #include<cmath> ...
- Circular placeholder reference 'server.port' in property definitions
Exception in thread "main" java.lang.IllegalArgumentException: Circular placeholder refere ...
- 【HDOJ】2772 Matchsticks
纯粹的找规律题.1: 22: 53: 54: 45: 56: 67: 38: 79: 60: 6 2 1 13 7 74 4 115 2 ...
- Currency Exchange(判断是否有正环)
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16456 Accepted: 5732 Description Seve ...