Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit 19a5272

Browse files
Gabriel DelépineGabriel Delépine
Gabriel Delépine
authored and
Gabriel Delépine
committed
Merge pull request #20 from lifter035/main
Scope retrieved from $rootElement instead of <head>
2 parents b26a962 + c541e53 commit 19a5272

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

angular-css-injector.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ angular.module('angular.css.injector', [])
1010
.provider('cssInjector', function() {
1111
var singlePageMode = false;
1212

13-
function CssInjector($compile, $rootScope){
13+
function CssInjector($compile, $rootScope, $rootElement){
1414
// Variables
1515
var head = angular.element(document.getElementsByTagName('head')[0]),
1616
scope;
@@ -27,8 +27,7 @@ angular.module('angular.css.injector', [])
2727
{
2828
if(scope === undefined)
2929
{
30-
if((scope = head.scope()) === undefined) // We initialise head's scope in a separated function because it is not defined at the time of the initialisation of the service.
31-
throw("angular.css.injector error : Please initialize your app in the HTML tag and be sure your page has a HEAD tag.");
30+
scope = $rootElement.scope();
3231
}
3332
};
3433

@@ -83,8 +82,8 @@ angular.module('angular.css.injector', [])
8382
};
8483
}
8584

86-
this.$get = ['$compile', '$rootScope', function($compile, $rootScope){
87-
return new CssInjector($compile, $rootScope);
85+
this.$get = ['$compile', '$rootScope', '$rootElement', function($compile, $rootScope, $rootElement){
86+
return new CssInjector($compile, $rootScope, $rootElement);
8887
}];
8988

9089
this.setSinglePageMode = function(mode){

0 commit comments

Comments
 (0)