<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.active1{ background:red;}
.active2{ background:blue;}
</style>
<script src="angular.min.js"></script>
<script>
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope',function($scope){
$scope.dataList = [
'aaaaa' , 'bbbbb' , 'cccccc' , 'dddddd' , 'eeeeee'
];
}]);
</script>
</head>
<body>
<div ng-controller="Aaa">
<input type="checkbox" ng-model="aaa"> //checkbox选中则aaa为true
<select>
<option></option>
<option ng-selected="aaa"></option> //下拉选择框是否选择取决于aaa变量
</select>
//输入框变化就会出发输入框的值为hello
<input type="text" ng-change="bbb='hello'" ng-model="bbb">{{bbb}}<br>
//ng-paste="ccc=true"当输入框复制操作时时ccc=true,
<input type="text" value="aasdassssssss" ng-paste="ccc=true">{{ccc}}
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script>
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope','$interval',function($scope,$interval){
var iNow = ;
$scope.text = iNow+'秒';
$scope.isDisabled = true;
//setInterval -> $scope.$apply()
//$timeout $interval
var timer = $interval(function(){
iNow--;
$scope.text = iNow+'秒'; if(iNow == ){
$interval.cancel(timer);
$scope.text = '可以点击啦';
$scope.isDisabled = false;
}
},);
}]);
</script>
</head>
<body>
<div ng-controller="Aaa">
//ng-disabled="isDisabled",isDisabled是变量名
<input type="button" ng-value="text" ng-disabled="isDisabled">
<input type="text" value="{{text}}" ng-readonly="isDisabled">
<input type="checkbox" value="{{text}}" ng-checked="isDisabled">
</div>
<script>
alert();
</script>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
//引入插件,ngSanitize模块
<script src="http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular-sanitize.min.js"></script>
<script>
var m1 = angular.module('myApp',['ngSanitize']); //['ngSanitize']是引入ngSanitize模块
m1.controller('Aaa',['$scope',function($scope){
$scope.text = '<h1>hello</h1>';
}]);
</script>
</head>
<body>
<div ng-controller="Aaa">
<div ng-bind="text"></div> //跟ng-value和写表达式是一样的
<div ng-bind-template="{{text}},{{text}}"></div> //ng-bind-template用于写多个表达式
<div ng-bind-html="text"></div> //解析html内容,要引入ngSanitize模块
<div ng-cloak>{{text}}</div> //ng-cloak用于没有解析完毕时不显示解析完毕后解析,用户体验好。
<div ng-non-bindable>{{text}}</div> //原样输出,不进行解析。
</div>
<script>
alert(); //阻止后面的js的执行
</script>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
.red{ background:red;}
.yellow{ background:yellow;}
</style>
<script src="angular.min.js"></script>
<script>
var m1 = angular.module('myApp',[]);
m1.controller('Aaa',['$scope',function($scope){
$scope.text = 'hello';
$scope.style = "{color:'red',background:'yellow'}";
$scope.sClass = "{red:true,yellow:true}";
$scope.url = "http://www.baidu.com";
}]);
</script>
</head> <body>
<div ng-controller="Aaa">
<div ng-class="{red:true}">{{text}}</div> //激活red样式
<div ng-class="{red:true,yellow:true}">{{text}}</div> //激活red和yellow样式
<div ng-class="{{sClass}}">{{text}}</div>
<div ng-style="{color:'red',background:'yellow'}">{{text}}</div>
<div ng-style="{{style}}">{{text}}</div>
<a ng-href="{{url}}">aaaaaaa</a>
<a ng-attr-href="{{url}}" ng-attr-title="{{text}}" ng-attr-class="" ng-attr-style="">aaaaaaa</a>
</div>
<script>
alert(); //阻止后面js的执行
</script>
</body>
</html>

angularjs 标签指令的更多相关文章

  1. AngularJS之指令

    紧接上篇博客“初探AngularJS” 一.前言 在AngularJS中指令尤为重要且内容庞多,固单独提炼出来,梳理一番.如有错误,请不吝讲解. 好了,言归正传,让我们一起走进Angular指令的世界 ...

  2. 带你走近AngularJS - 体验指令实例

    带你走近AngularJS系列: 带你走近AngularJS - 基本功能介绍 带你走近AngularJS - 体验指令实例 带你走近AngularJS - 创建自定义指令 ------------- ...

  3. 《AngularJS》--指令的相互调用

    转载自http://blog.csdn.net/zhoukun1008/article/details/51296692 人们喜欢AngularJS,因为他很有特色,其中他的指令和双向数据绑定很吸引着 ...

  4. 学习AngularJs:Directive指令用法(完整版)

    这篇文章主要学习AngularJs:Directive指令用法,内容很全面,感兴趣的小伙伴们可以参考一下   本教程使用AngularJs版本:1.5.3 AngularJs GitHub: http ...

  5. AngularJs:Directive指令用法

    摘自:http://www.jb51.net/article/83051.htm 摘要:Directive(指令)是AngularJ非常强大而有有用的功能之一.它就相当于为我们写了公共的自定义DOM元 ...

  6. 【js类库AngularJs】学习angularJs的指令(包括常见表单验证,隐藏等功能)

    [js类库AngularJs]学习angularJs的指令(包括常见表单验证,隐藏等功能) AngularJS诞生于2009年,由Misko Hevery 等人创建,后为Google所收购.是一款优秀 ...

  7. AngularJs自定义指令详解(2) - template

    一些用于定义行为的指令,可能不需要使用template参数. 当指定template参数时,其值可以是一个字符串,表示一段HTML文本,也可以是一个函数,这函数接受两个参数:tElement和tAtt ...

  8. AngularJs自定义指令详解(1) - restrict

    下面所有例子都使用angular-1.3.16.下载地址:http://cdn.bootcss.com/angular.js/1.3.16/angular.min.js 既然AngularJs快要发布 ...

  9. angularJS自定义指令间的“沟通”

    由此例子我们可以看出,angularJS使用指令时link的执行顺序<html> <head> <meta charset="utf-8"/> ...

随机推荐

  1. POJ2891 Strange Way to Express Integers (扩展欧几里德)

    本文为博主原创文章,欢迎转载,请注明出处 www.cnblogs.com/yangyaojia 题目大意 求解一组同余方程 x ≡ r1 (mod a1) x ≡ r2 (mod a2) x ≡ r ...

  2. java判断string数组中是否包含某个元素

  3. 在Html5中与服务器交互

    转自原文 在Html5中与服务器交互 刚刚涉足职场,上头就要我研究HTML5,内嵌到手机上,这对我来说完全是一个陌生的领域,不过也正好给自己一个机会来学习,最近做到要跟服务器交互这部分,这部分可是卡了 ...

  4. oracle学习之第一个存储过程:打印Hello World

    数据库对象:表.视图.索引.序列.同义词.存储过程.存储函数 存储过程:指的是存储在数据库中供全部用户程序调用的子程序叫存储过程.存储函数 存储过程和存储函数的同样点:完毕特定功能的程序 存储过程和存 ...

  5. HDU 4307 Contest 1

    http://www.cnblogs.com/staginner/archive/2012/08/13/2636826.html 自己看过后两周吧,重新写了一遍.很受启发的.对于0.1,可以使用最小割 ...

  6. JavaScript DOM(一)

    文件夹: DOM家谱树 节点的基本属性和方法 document与getElement方法 DOM家谱树 DOM能够将不论什么HTML或XML文档描绘成一个由多层次节点构成的结构.当中节点被分为几种不同 ...

  7. ES API 备忘

    本文所列的所有API在ElasticSearch文档是有详尽的说明,但它的结构组织的不太好. 这篇文章把ElasticSearch API用表格的形式供大家参考. https://www.iteblo ...

  8. 细述 Java垃圾回收机制→Types of Java Garbage Collectors

    细述 Java垃圾回收机制→Types of Java Garbage Collectors 转自:https://segmentfault.com/a/1190000006214497 本文非原创, ...

  9. C#中的CSP(Communicating sequential processes)

    说起Golang(后面统称为Go),就想到他的高并发特性,在深入一些就是 Goroutine.在大家被它优雅的语法和简洁的代码实现的高并发程序所折服时,其实C#/.NET也可以很容易的做到.今天我们来 ...

  10. 《汇编语言(第三版)》pushf 和 popf 指令,以及标志寄存器在 Debug 中的表示

    pushf 和 popf pushf 的功能是将标志寄存器的值压栈,而 popf 是从栈中弹出数据,输入标志寄存器. pushf 和 popf,为直接访问寄存器提供了方法. 格式 pushf popf ...