From ed36b9da3be338fe9eb36f3eeea901d6f51cd768 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 1 Nov 2011 21:09:54 -0700 Subject: refactor(injector): switch to injector 2.0 introduce modules --- src/service/compiler.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/service/compiler.js') diff --git a/src/service/compiler.js b/src/service/compiler.js index c1728f7d..0bd3e54d 100644 --- a/src/service/compiler.js +++ b/src/service/compiler.js @@ -22,14 +22,15 @@ angularServiceInject('$compile', function($injector, $exceptionHandler, $textMar Template.prototype = { link: function(element, scope) { - var childScope = scope; + var childScope = scope, + locals = {$element: element}; if (this.newScope) { childScope = isFunction(this.newScope) ? scope.$new(this.newScope(scope)) : scope.$new(); element.data($$scope, childScope); } forEach(this.linkFns, function(fn) { try { - childScope.$service.invoke(childScope, fn, [element]); + $injector.invoke(childScope, fn, locals); } catch (e) { $exceptionHandler(e); } @@ -54,6 +55,10 @@ angularServiceInject('$compile', function($injector, $exceptionHandler, $textMar addLinkFn:function(linkingFn) { if (linkingFn) { + //TODO(misko): temporary hack. + if (isFunction(linkingFn) && !linkingFn.$inject) { + linkingFn.$inject = ['$element']; + } this.linkFns.push(linkingFn); } }, -- cgit v1.2.3