forked from castillo-io/angular-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.states.js
177 lines (166 loc) · 4.93 KB
/
app.states.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* Include 'angularCSS' as a dependency
* ui.router is optional (no configuration required)
*/
var myApp = angular.module('myApp', ['ui.router','angularCSS','hljs']);
/**
* States definition example
*/
myApp.config(function($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('/');
/**
* State provider settings
*/
$stateProvider
.state('black', {
url: '/black',
title: 'Black',
templateUrl: 'pages/black/page-black.html',
/* Now we can bind css to states */
css: 'pages/black/page-black.css',
views: {
'state1': {
templateUrl: 'pages/black/states/state-black1.html',
/* and state views */
css: 'pages/black/states/state-black1.css'
},
'state2': {
templateUrl: 'pages/black/states/state-black2.html',
css: ['pages/black/states/state-black2.css']
},
'state3': {
templateUrl: 'pages/black/states/state-black3.html',
css: {
href: 'pages/black/states/state-black3.css'
}
}
}
})
.state('cyan', {
url: '/cyan',
title: 'Cyan',
templateUrl: 'pages/cyan/page-cyan.html',
/* We can also enable features like bust cache, persist and preload */
css: {
href: 'pages/cyan/page-cyan.css',
bustCache: true
},
views: {
'state1': {
templateUrl: 'pages/cyan/states/state-cyan1.html',
css: 'pages/cyan/states/state-cyan1.css'
},
'state2': {
templateUrl: 'pages/cyan/states/state-cyan2.html',
css: ['pages/cyan/states/state-cyan2.css']
},
'state3': {
templateUrl: 'pages/cyan/states/state-cyan3.html',
css: {
href: 'pages/cyan/states/state-cyan3.css'
}
}
}
})
.state('magenta', {
url: '/magenta',
title: 'Magenta',
templateUrl: 'pages/magenta/page-magenta.html',
/* This is how we can include multiple stylesheets */
css: ['pages/magenta/page-magenta.css','pages/magenta/page-magenta2.css'],
views: {
'state1': {
templateUrl: 'pages/magenta/states/state-magenta1.html',
css: 'pages/magenta/states/state-magenta1.css'
},
'state2': {
templateUrl: 'pages/magenta/states/state-magenta2.html',
css: ['pages/magenta/states/state-magenta2.css']
},
'state3': {
templateUrl: 'pages/magenta/states/state-magenta3.html',
css: {
href: 'pages/magenta/states/state-magenta3.css'
}
}
}
})
.state('yellow', {
url: '/yellow',
title: 'Yellow',
templateUrl: 'pages/yellow/page-yellow.html',
views: {
'state1': {
templateUrl: 'pages/yellow/states/state-yellow1.html',
css: 'pages/yellow/states/state-yellow1.css'
},
'state2': {
templateUrl: 'pages/yellow/states/state-yellow2.html',
css: ['pages/yellow/states/state-yellow2.css']
},
'state3': {
templateUrl: 'pages/yellow/states/state-yellow3.html',
css: {
href: 'pages/yellow/states/state-yellow3.css'
}
}
},
css: [
{
href: 'pages/yellow/page-yellow.css'
}, {
href: 'pages/yellow/page-yellow.mobile.css',
/* Media Query support via window.matchMedia API
* This will only add the stylesheet if the breakpoint matches. Give it a try! */
media: '(max-width : 768px)'
}, {
href: 'pages/yellow/page-yellow.print.css',
media: 'print'
}
]
})
.state('home', {
url: '/',
title: 'Home',
templateUrl: 'pages/home/page-home.html'
});
});
/**
* Directive Definition Object (DDO) examples
*/
myApp.component('black', {
templateUrl: 'directives/black/directive-black.html',
css: 'directives/black/directive-black.css' /* Binding css to component */
});
myApp.component('cyan', {
templateUrl: 'directives/cyan/directive-cyan.html',
css: { /* Same syntax as in the routes example applies here */
href: 'directives/cyan/directive-cyan.css',
bustCache: true
}
});
myApp.directive('magenta', function () {
return {
restrict: 'E',
replace: true,
templateUrl: 'directives/magenta/directive-magenta.html',
css: {
href: 'directives/magenta/directive-magenta.css',
/* Preload: this will trigger an HTTP request on app load.
* Once the stylesheet is added, it will be loaded from the browser cache */
preload: true
}
}
});
myApp.directive('yellow', function () {
return {
restrict: 'E',
replace: true,
templateUrl: 'directives/yellow/directive-yellow.html',
css: {
href: 'directives/yellow/directive-yellow.css',
/* Persist: The stylesheet won't be removed even after the directive has been destroyed */
persist: true
}
}
});