9
9
angular . module ( 'angular.css.injector' , [ ] )
10
10
. provider ( 'cssInjector' , function ( ) {
11
11
var singlePageMode = false ;
12
-
12
+
13
13
function CssInjector ( $compile , $rootScope ) {
14
14
// Variables
15
15
var singlePageMode = false ,
16
16
head = angular . element ( document . getElementsByTagName ( 'head' ) [ 0 ] ) ,
17
17
scope ;
18
-
18
+
19
19
// Capture the event `locationChangeStart` when the url change. If singlePageMode===TRUE, call the function `removeAll`
20
20
$rootScope . $on ( '$locationChangeStart' , function ( )
21
21
{
@@ -32,12 +32,12 @@ angular.module('angular.css.injector', [])
32
32
throw ( "angular.css.injector error : Please initialize your app in the HTML tag and be sure your page has a HEAD tag." ) ;
33
33
}
34
34
} ;
35
-
35
+
36
36
// Used to add a CSS files in the head tag of the page
37
37
var addStylesheet = function ( href )
38
38
{
39
39
_initScope ( ) ;
40
-
40
+
41
41
if ( scope . injectedStylesheets === undefined )
42
42
{
43
43
scope . injectedStylesheets = [ ] ;
@@ -51,29 +51,29 @@ angular.module('angular.css.injector', [])
51
51
return ;
52
52
}
53
53
}
54
-
54
+
55
55
scope . injectedStylesheets . push ( { href : href } ) ;
56
56
} ;
57
-
57
+
58
58
// Used to remove all of the CSS files added with the function `addStylesheet`
59
59
var removeAll = function ( )
60
60
{
61
61
_initScope ( ) ;
62
-
62
+
63
63
if ( scope . injectedStylesheets !== undefined )
64
64
scope . injectedStylesheets = [ ] ; // Make it empty
65
65
} ;
66
-
66
+
67
67
return {
68
68
add : addStylesheet ,
69
69
removeAll : removeAll
70
70
} ;
71
71
}
72
-
72
+
73
73
this . $get = function ( $compile , $rootScope ) {
74
74
return new CssInjector ( $compile , $rootScope ) ;
75
75
} ;
76
-
76
+
77
77
this . setSinglePageMode = function ( mode ) {
78
78
singlePageMode = mode ;
79
79
return this ;
0 commit comments