diff options
Diffstat (limited to 'src/Scope.js')
| -rw-r--r-- | src/Scope.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Scope.js b/src/Scope.js index 562dfbd8..b41f7436 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -1,4 +1,4 @@ -function getter(instance, path) { +function getter(instance, path, unboundFn) { if (!path) return instance; var element = path.split('.'); var key; @@ -22,7 +22,7 @@ function getter(instance, path) { } } } - if (typeof instance === 'function' && !instance['$$factory']) { + if (!unboundFn && isFunction(instance) && !instance['$$factory']) { return bind(lastInstance, instance); } return instance; @@ -146,7 +146,17 @@ function createScope(parent, services, existing) { fn: expressionCompile(expr), handler: exceptionHandler }); + }, + + $become: function(Class) { + // remove existing + foreach(behavior, function(value, key){ delete behavior[key]; }); + foreach((Class || noop).prototype, function(fn, name){ + behavior[name] = bind(instance, fn); + }); + (Class || noop).call(instance); } + }); if (!parent.$root) { |
