From 4b35a59c6afd5093ed5ce7d68b75ccadd4c53696 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 7 Nov 2011 21:55:41 -0800 Subject: refactor(scenario): fix scenario bootstrap & publish injector for inspection --- example/personalLog/scenario/personalLogScenario.js | 5 +++-- src/Angular.js | 4 +++- src/scenario/Application.js | 9 ++++++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/example/personalLog/scenario/personalLogScenario.js b/example/personalLog/scenario/personalLogScenario.js index 355761bd..f9a37cf4 100644 --- a/example/personalLog/scenario/personalLogScenario.js +++ b/example/personalLog/scenario/personalLogScenario.js @@ -81,8 +81,9 @@ angular.scenario.dsl('clearCookies', function() { */ return function() { this.addFutureAction('clear all cookies', function($window, $document, done) { - var rootScope = $window.angular.element($document[0]).data('$scope'), - $cookies = rootScope.$service('$cookies'), + var element = $window.angular.element($document[0]), + rootScope = element.scope(), + $cookies = element.data('$injector')('$cookies'), cookieName; rootScope.$apply(function() { diff --git a/src/Angular.js b/src/Angular.js index e8bb3880..7b9bd1db 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -956,7 +956,9 @@ function angularInit(config, document){ }); createInjector(modules, angularModule)(['$rootScope', '$compile', '$injector', function(scope, compile, injector){ scope.$apply(function(){ - compile(isString(autobind) ? document.getElementById(autobind) : document)(scope); + var element = jqLite(isString(autobind) ? document.getElementById(autobind) : document); + element.data('$injector', injector); + compile(element)(scope); }); }]); } diff --git a/src/scenario/Application.js b/src/scenario/Application.js index 1a87141f..ef778975 100644 --- a/src/scenario/Application.js +++ b/src/scenario/Application.js @@ -90,8 +90,11 @@ angular.scenario.Application.prototype.executeAction = function(action) { if (!$window.angular) { return action.call(this, $window, _jQuery($window.document)); } - var $browser = $window.angular.service.$browser(); - $browser.notifyWhenNoOutstandingRequests(function() { - action.call(self, $window, _jQuery($window.document)); + var element = $window.angular.element($window.document.body); + var $injector = element.inheritedData('$injector'); + $injector(function($browser){ + $browser.notifyWhenNoOutstandingRequests(function() { + action.call(self, $window, _jQuery($window.document)); + }); }); }; -- cgit v1.2.3