From dee68c72bd2f7535ba17d0d005859c37a3a117c5 Mon Sep 17 00:00:00 2001 From: Maciek Ruckgaber Date: Fri, 6 Jun 2014 17:19:52 +0200 Subject: [PATCH] Fixes $compile $rootScope bug when minifying source $compile and $rootScope are not properly injected when using the non minified version of the library. It is better practice to explicitly inject those using array syntax. --- angular-css-injector.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/angular-css-injector.js b/angular-css-injector.js index 69fa027..886d66a 100644 --- a/angular-css-injector.js +++ b/angular-css-injector.js @@ -8,9 +8,9 @@ */ angular.module('angular.css.injector', []) .provider('cssInjector', function() { - var singlePageMode = false; - - function CssInjector($compile, $rootScope){ + var singlePageMode = false; + + function CssInjector($compile, $rootScope){ // Variables var singlePageMode = false, head = angular.element(document.getElementsByTagName('head')[0]), @@ -63,19 +63,19 @@ angular.module('angular.css.injector', []) if(scope.injectedStylesheets !== undefined) scope.injectedStylesheets = []; // Make it empty }; - + return { add: addStylesheet, removeAll: removeAll }; - } - - this.$get = function($compile, $rootScope){ - return new CssInjector($compile, $rootScope); - }; - - this.setSinglePageMode = function(mode){ - singlePageMode = mode; - return this; - } + } + + this.$get = ['$compile', '$rootScope', function($compile, $rootScope){ + return new CssInjector($compile, $rootScope); + }]; + + this.setSinglePageMode = function(mode){ + singlePageMode = mode; + return this; + } });