From d9abfe8a7e488be8725f56077527b16f7c79546a Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 8 Oct 2010 17:30:13 -0700 Subject: Introduced injector and $new to scope, and injection into link methods and controllers - added angular.injector(scope, services, instanceCache) which returns inject - inject method can return, instance, or call function which have $inject property - initialize services with $creation=[eager|eager-publish] this means that only some of the services are now globally accessible - upgraded $become on scope to use injector hence respect the $inject property for injection - $become should not be run multiple times and will most likely be removed in future version - added $new on scope to create a child scope - $inject is respected on constructor function - simplified scopes so that they no longer have separate __proto__ for parent, api, behavior and instance this should speed up execution since scope will now create one __proto__ chain per scope (not three). BACKWARD COMPATIBILITY WARNING: - services now need to have $inject instead of inject property for proper injection this breaks backward compatibility - not all services are now published into root scope (only: $location, $cookie, $window) - if you have widget/directive which uses services on scope (such as this.$xhr), you will now have to inject that service in (as it is not published on the root scope anymore) --- test/widgetsSpec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/widgetsSpec.js') diff --git a/test/widgetsSpec.js b/test/widgetsSpec.js index 80acc928..8f6ccaea 100644 --- a/test/widgetsSpec.js +++ b/test/widgetsSpec.js @@ -476,7 +476,7 @@ describe("widget", function(){ scope.childScope = createScope(); scope.childScope.name = 'misko'; scope.url = 'myUrl'; - scope.$xhr.cache.data.myUrl = {value:'{{name}}'}; + scope.$inject('$xhr.cache').data.myUrl = {value:'{{name}}'}; scope.$init(); expect(element.text()).toEqual('misko'); }); @@ -487,7 +487,7 @@ describe("widget", function(){ scope.childScope = createScope(); scope.childScope.name = 'igor'; scope.url = 'myUrl'; - scope.$xhr.cache.data.myUrl = {value:'{{name}}'}; + scope.$inject('$xhr.cache').data.myUrl = {value:'{{name}}'}; scope.$init(); expect(element.text()).toEqual('igor'); -- cgit v1.2.3