diff options
| author | Misko Hevery | 2012-01-27 16:18:16 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2012-02-21 22:46:00 -0800 | 
| commit | 78656fe0dfc99c341ce02d71e7006e9c05b1fe3f (patch) | |
| tree | a68731c4c1675047da65b23ccf3d562324324081 /src/service/scope.js | |
| parent | cb10ccc44fa78b82c80afa1cb5dac2c34fdf24b7 (diff) | |
| download | angular.js-78656fe0dfc99c341ce02d71e7006e9c05b1fe3f.tar.bz2 | |
feat($compile) add locals, isolate scope, transclusion
Diffstat (limited to 'src/service/scope.js')
| -rw-r--r-- | src/service/scope.js | 34 | 
1 files changed, 25 insertions, 9 deletions
diff --git a/src/service/scope.js b/src/service/scope.js index 9b9e9215..da1062a8 100644 --- a/src/service/scope.js +++ b/src/service/scope.js @@ -136,20 +136,36 @@ function $RootScopeProvider(){         * the scope and its child scopes to be permanently detached from the parent and thus stop         * participating in model change detection and listener notification by invoking.         * +       * @params {boolean} isolate if true then the scoped does not prototypically inherit from the +       *         parent scope. The scope is isolated, as it can not se parent scope properties. +       *         When creating widgets it is useful for the widget to not accidently read parent +       *         state. +       *         * @returns {Object} The newly created child scope.         *         */ -      $new: function() { -        var Child = function() {}; // should be anonymous; This is so that when the minifier munges -          // the name it does not become random set of chars. These will then show up as class -          // name in the debugger. -        var child; -        Child.prototype = this; -        child = new Child(); +      $new: function(isolate) { +        var Child, +            child; + +        if (isFunction(isolate)) { +          // TODO: remove at some point +          throw Error('API-CHANGE: Use $controller to instantiate controllers.'); +        } +        if (isolate) { +          child = new Scope(); +          child.$root = this.$root; +        } else { +          Child = function() {}; // should be anonymous; This is so that when the minifier munges +            // the name it does not become random set of chars. These will then show up as class +            // name in the debugger. +          Child.prototype = this; +          child = new Child(); +          child.$id = nextUid(); +        }          child['this'] = child;          child.$$listeners = {};          child.$parent = this; -        child.$id = nextUid();          child.$$asyncQueue = [];          child.$$watchers = child.$$nextSibling = child.$$childHead = child.$$childTail = null;          child.$$prevSibling = this.$$childTail; @@ -277,7 +293,7 @@ function $RootScopeProvider(){         * `'Maximum iteration limit exceeded.'` if the number of iterations exceeds 100.         *         * Usually you don't call `$digest()` directly in -       * {@link angular.module.ng.$compileProvider.directive.ng:controller controllers} or in  +       * {@link angular.module.ng.$compileProvider.directive.ng:controller controllers} or in         * {@link angular.module.ng.$compileProvider.directive directives}.         * Instead a call to {@link angular.module.ng.$rootScope.Scope#$apply $apply()} (typically from within a         * {@link angular.module.ng.$compileProvider.directive directives}) will force a `$digest()`.  | 
