From 48697a2b86dbb12ea8de64cc5fece7caf68b321e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 17 Oct 2011 16:56:56 -0700 Subject: refactor(injector): turn scope into a service - turn scope into a $rootScope service. - injector is now a starting point for creating angular application. - added inject() method which wraps jasmine its/beforeEach/afterEach, and which allows configuration and injection of services. - refactor tests to use inject() where possible BREAK: - removed angular.scope() method --- src/service/cookies.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/service/cookies.js') diff --git a/src/service/cookies.js b/src/service/cookies.js index a2ccee09..2cd2b9d6 100644 --- a/src/service/cookies.js +++ b/src/service/cookies.js @@ -13,9 +13,8 @@ * * @example */ -angularServiceInject('$cookies', function($browser) { - var rootScope = this, - cookies = {}, +angularServiceInject('$cookies', function($rootScope, $browser) { + var cookies = {}, lastCookies = {}, lastBrowserCookies, runEval = false; @@ -27,7 +26,7 @@ angularServiceInject('$cookies', function($browser) { lastBrowserCookies = currentCookies; copy(currentCookies, lastCookies); copy(currentCookies, cookies); - if (runEval) rootScope.$apply(); + if (runEval) $rootScope.$apply(); } })(); @@ -36,7 +35,7 @@ angularServiceInject('$cookies', function($browser) { //at the end of each eval, push cookies //TODO: this should happen before the "delayed" watches fire, because if some cookies are not // strings or browser refuses to store some cookies, we update the model in the push fn. - this.$watch(push); + $rootScope.$watch(push); return cookies; @@ -90,4 +89,4 @@ angularServiceInject('$cookies', function($browser) { } } } -}, ['$browser']); +}, ['$rootScope', '$browser']); -- cgit v1.2.3