angularjs1继承问题
来源:互联网 发布:http协议的端口号 编辑:程序博客网 时间:2024/06/03 22:47
angularjs代码:<script> (function () { var root = angular.module("root",["m1"]); var m1 = angular.module("m1",[]); m1.controller("m1One",function ($scope) { $scope.msg = "hello m1 one" }); m1.controller("m1Two",function ($scope) { $scope.msg = "hello m1 Two"; $scope.pmsg = $scope.$parent.msg;() }); m1.controller("m1Three",function ($scope) { $scope.msg = "hello m1 Three"; $scope.pmsg = $scope.$parent.msg; $scope.gmsg = $scope.$parent.$parent.msg; }) })()</script>html代码:<div ng-controller="m1One" class="well"> {{msg}} <div ng-controller="m1Two" class="well"> {{pmsg}} --{{msg}} <div ng-controller="m1Three" class="well"> {{pmsg}} ----- {{msg}} <hr> {{gmsg}} </div> </div> </div>其运行结果为:
拓展:
$scope.$parent
本质:子域不继承父域,并建立独立作用域。
、当scope对象为空对象时,无论是父域parentName,还是指令子域parentName发生变更,都不会影响到对方。
原理很清楚,就是指令建立的独立作用域,与父域是完全隔离的。
阅读全文
0 0
- angularjs1继承问题
- AngularJs1 待续
- AngularJS1.4.6
- 继承问题
- 继承问题
- Angularjs1.x 项目结构
- angularjs1.0使用总结
- angularJS1界面跳转
- angularJS1 数据绑定demo
- angularJS1 $cookies用法
- angularJS1 get post请求
- angularJS1 Error: [$location:nobase]
- angularJS1 log打印日志
- angularJS1 数据类型判断
- angularJS1 Error: [jqLite:nosel]
- angularJS1 路由配置
- angularJS1 路由隐藏tab
- AngularJs1学习之--ngModel
- ElasticSearch-多索引检索与批量操作
- Android控件布局属性全解
- distribute candies
- c#TextBox输入框自动提示、自动完成、自动补全功能
- 思维导图get面试新技能
- angularjs1继承问题
- 字符统计
- VirtualBox 下安装CentOS-6.5
- 机器学习--归一化
- 订单商品信息跨页面传递中的加密与解密及过滤特殊字符串
- BZOJ 1044 洛谷 2511 [HAOI2008] 木棍分割
- 基于Spark和SparkSQL的NetFlow流量的初步分析——scala语言
- ubuntu sudo: 未找到命令
- 实现舞会上男女舞伴的自动匹配。