angularJS学习之路(十九)---自定义指令关于独立作用域
来源:互联网 发布:生意参谋数据抓取 编辑:程序博客网 时间:2024/04/30 05:43
1.首先关于 scope:{} 和scope:true 效果是一样的
<!DOCTYPE html><html ng-app="myApp"><head><meta charset="utf-8"><title></title></head><body><div ng-init="myProperty = 'wow, this is cool'"></div>Surrounding scope: {{ myProperty }}<div myInheritScopeDirective="SomeCtrl">Inside an directive with inherited scope: {{ myProperty }}</div><div myDirective>Inside myDirective, isolate scope: {{ myProperty }}</div><script type="text/javascript" src="../js/angular.min.js"></script><script>var app = angular.module('myApp', []);app.directive('myDirective', function() {return {restrict: 'A',scope: {}};});app.directive('myInheritScopeDirective', function() {return {restrict: 'A',scope: true};});</script></body></html>
2.关于不设置scope:true的时候非独立作用域的效果
<!doctype html><html ng-app="myApp"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div><xingoo></xingoo><xingoo></xingoo><xingoo></xingoo></div><script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script><script type="text/javascript">var myAppModule = angular.module("myApp", []);myAppModule.directive("xingoo", function() {return {restrict: 'AE',template: '<div><input type="text" ng-model="username"/>{{username}}</div><br>',repalce: true}})</script></body></html>
<!doctype html><html ng-app="myApp"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><div><xingoo></xingoo><xingoo></xingoo><xingoo></xingoo></div><script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script><script type="text/javascript">var myAppModule = angular.module("myApp", []);myAppModule.directive("xingoo", function() {return {restrict: 'AE',scope: {},template: '<div><input type="text" ng-model="username"/>{{username}}</div><br>',repalce: true}})</script></body></html>
0 0
- angularJS学习之路(十九)---自定义指令关于独立作用域
- angularJS学习之路(二十)---自定义指令作用域绑定策略问题
- angularJS学习之路(二十)---自定义指令---transclude的作用
- AngularJS学习之指令作用域
- angularJS学习之路(二十九)---控制器的别名使用 和它的作用域的确定
- angularJS学习之路(十七)---自定义指令
- angularJS学习之路(十八)---自定义指令执行过程
- angularJS学习之路(三十)---自定义指令---templateUrl
- angularjs指令的独立作用域和绑定策略
- AngularJS学习之directive自定义指令
- angularJS学习之路(六)---指令
- AngularJS学习笔记(一):表达式&指令&作用域
- angularJS之自定义指令
- angularJS学习之路(四)---作用域(1)
- 创建自定义 AngularJS 指令:Part 2 孤立作用域
- Angularjs自定义指令之面包屑
- Angularjs自定义指令之复制指令
- [AngularJS]—— 12 独立作用域
- 详谈ByteArrayOutputStream的用法
- 【鸟哥的linux私房菜-学习笔记】网络安全与主机基本防护
- Qt5之控件的隐藏显示与移动
- UI第十天:UITableView 编辑
- Qt透明按钮控件
- angularJS学习之路(十九)---自定义指令关于独立作用域
- 史上最全IOS的touch事件手势使用方法
- java.util.Date、java.sql.Date、java.sql.Time、java.sql.Timestamp区别和联系
- QT图片透明的设置
- The server does not support version 3.0 of the J2EE Web module specification
- 关于跳槽的11条建议
- 线段树
- 将短链接转化成正常链接
- Android进程间通信(二):AIDL