`
smiky
  • 浏览: 253985 次
  • 性别: Icon_minigender_1
  • 来自: 天门
社区版块
存档分类
最新评论

isolate scope与scope的区别

阅读更多

普通的$scope可以获取到父类的属性,如同prototype继承一样

isolate $scope则只能找到它自己的属性

原理很简单:$scope将prototype直接指向了其父$scope,而$scope没有,居然其它的属性是一样的,但是在进行属性查找时是有分别的。

在$rootScope中:
$new: function(isolate, parent) {
        var child;

        parent = parent || this;

        if (isolate) {
          child = new Scope();
          child.$root = this.$root;
        } else {
          // Only create a child scope class if somebody asks for one,
          // but cache it to allow the VM to optimize lookups.
          if (!this.$$ChildScope) {
            this.$$ChildScope = function ChildScope() {
              this.$$watchers = this.$$nextSibling =
                  this.$$childHead = this.$$childTail = null;
              this.$$listeners = {};
              this.$$listenerCount = {};
              this.$id = nextUid();
              this.$$ChildScope = null;
            };
            this.$$ChildScope.prototype = this;
          }
          child = new this.$$ChildScope();
        }
        child.$parent = parent;

 

分享到:
评论

相关推荐

    AngularJS中isolate scope的用法分析

    主要介绍了AngularJS中isolate scope的用法,结合实例形式分析了isolate scope的几种具体使用方式,需要的朋友可以参考下

    AngularJS全局scope与Isolate scope通信用法示例

    主要介绍了AngularJS全局scope与Isolate scope通信用法,结合格式分析了全局scope和directive本地scope相关功能、通信用法与相关注意事项,需要的朋友可以参考下

    AngularJs14-16

    AngularJS - 14 Directives Talking to Controllers AngularJS - 16 Understanding Isolate Scope

    Egghead_Tutorial:Egghead 的 Angular 教程

    Angular 教程 Egghead 动画片深拷贝对象指示元素指令属性指令基本的jQuery 高级jQuery 与 Ctrl 进行指令对话指令与指令对话隔离范围 & 隔离作用域@ Isolate Scope =(双向绑定) HTTP http q_all routeProvider...

    addon-example:通过直接使用实现的nodejs插件示例

    为所有在当前scope中执行的操作设置执行某些。 手柄范围 管理local handles的生命周期。 功能模板 创建了运行时函数的模板,在一个Context中,只能有一个Function从模板中创建出来。可以在FunctionTemplate上设置...

    JavaScript-Demos:JavaScript 演示

    JavaScript 演示 (在) 这是基于我在我的博客上的博客文章的在线 JavaScript 演示的。 基本上,所有代码都已经在我的博客上了; 但是,我想要一种轻松创建读者可以玩的...AngularJS 1.2 中 Isolate-Scope 行为的重

    Amber:用于构建交互式 JavaScript 网站的模块化视图系统

    文档琥珀色 var ExampleView = Amber.View.Extend({/** * This is the element the view will isolate it's scope to * * @type {Object} */$el: $('.view-container'),/** * Lodash Inline Template

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Table of Contents Header Files The #define Guard Header File Dependencies Inline Functions The -inl.h Files Function Parameter Ordering Names and Order of Includes Scoping Namespaces Nested Classes ...

    beginning_portable_shell_scripting_from_novice_to_professional.pdf

    About the Author . . . . . . . . . ....About the Technical Reviewer ....Acknowledgments ....introduction to Shell Scripting ....About This Book ....Conventions ....What Shell Scripting Is ....What Shell Scripting Isn’t ....

Global site tag (gtag.js) - Google Analytics