-
Notifications
You must be signed in to change notification settings - Fork 86
/
app.routes.js
105 lines (95 loc) · 2.77 KB
/
app.routes.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
/**
* Include 'angularCSS' as a dependency
* ngRoute is optional (no configuration required)
*/
var myApp = angular.module('myApp', ['ngRoute','angularCSS','hljs']);
/**
* Routes definition example
*/
myApp.config(function($routeProvider) {
$routeProvider
.when('/black', {
title: 'Black',
templateUrl: 'pages/black/page-black.html',
/* Now we can bind css to routes */
css: 'pages/black/page-black.css'
})
.when('/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
}
})
.when('/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']
})
.when('/yellow', {
title: 'Yellow',
templateUrl: 'pages/yellow/page-yellow.html',
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'
}
]
})
.when('/', {
title: 'Home',
templateUrl: 'pages/home/page-home.html'
})
.otherwise({
redirectTo: '/'
});
});
/**
* 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
}
}
});