aboutsummaryrefslogtreecommitdiffstats
path: root/src/Scope.js
diff options
context:
space:
mode:
authorMisko Hevery2010-04-05 21:26:52 -0700
committerMisko Hevery2010-04-05 21:26:52 -0700
commite6460685869e16b5016de975fd0ba15a7e436951 (patch)
treebdf55503a5efd7e1922b73ab8ea0ac23c4137cf9 /src/Scope.js
parent2107eafcde390eebbf59e829194626c488de9e29 (diff)
downloadangular.js-e6460685869e16b5016de975fd0ba15a7e436951.tar.bz2
added ng-controller directive
Diffstat (limited to 'src/Scope.js')
-rw-r--r--src/Scope.js14
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) {