[AngularJS] Directive Communication, 'require'
39 angularjs directive require Communication
2023-09-14 09:00:56 时间
<!DOCTYPE html> <html> <head lang="en"> <meta charset="utf-8"> <title>Egghead Videos</title> <link rel="stylesheet" href="./foundation.min.css"> <script type="text/javascript" src="./angular.min.js"></script> <script type="text/javascript" src="./app.js"></script> </head> <body ng-app="app"> <country title="Finland"> <state title="North K"> <city title="Joensuu"> </city> </state> </country> </body> </html>
var app = angular.module("app", []); app.directive('country', function(){ return{ restrict: 'E', scope:{title: '@'}, controller: function(){ this.sayCountry = function(){ console.log("This is country: "); } } } }); app.directive('state',function(){ return{ restrict: 'E', scope:{title:'@'}, require: '^country', controller: function(){ this.sayState=function(){ console.log("This is state: "); } }, link: function(scope, element, attrs, countryCtrl){ countryCtrl.sayCountry(); } } }); app.directive('city',function(){ return{ restrict: 'E', scope: {title: '@'}, require: ['^country', '^state'], link:function(scope, element, attrs, ctrls){ console.log("This is city: "); ctrls[0].sayCountry(); ctrls[1].sayState(); } } });
相关文章
- Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
- Self referencing loop detected for property 'XXXXXX' with type
- python中if __name__ == '__main__': 的解析
- ZOJ 3804 YY's Minions (简单模拟)
- HDU 1400 (POJ 2411 ZOJ 1100)Mondriaan's Dream(DP + 状态压缩)
- UVA 10881 Piotr's Ants(等效变换 sort结构体排序)
- 【问题解决方案】关于Python中的语句 ' %matplotlib inline '
- [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope
- [AngularJS] Directive Communication, 'require'
- 【转载】Python 中 if __name__ == '__main__': 的作用
- [AngularJS + Unit Testing] Testing Directive's controller with bindToController, controllerAs and isolate scope
- Atitit python3.0 3.3 3.5 3.6 新特性 Python2.7新特性1Python 3_x 新特性1python3.4新特性1python3.5新特性1值得关注的新特性1Python3.6新特性2 Python2.7新特性Python 2.7的新特性 - 牛皮糖NewPtone - 博客园.html Python 3_x 新特性及10大变化_python_脚本之家.htm
- Atitit.编程语言and 自然语言的比较and 编程语言未来的发展
- atitit.TokenService token服务模块的设计
- Atitit. 如何判断软件工程师 能力模型 程序员能力模型 项目经理能力模型
- 【Codeforces Round #443 (Div. 2) A】Borya's Diagnosis
- 【例题5-3 UVA - 10815】Andy's First Dictionary
- jni项目创建出错 Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurfac
- Required String parameter ' ' is not present