File tree 3 files changed +60
-5
lines changed 3 files changed +60
-5
lines changed Original file line number Diff line number Diff line change 7
7
. run ( services )
8
8
. run ( redirection ) ;
9
9
10
- routing . $inject = [ '$stateProvider ' , '$urlRouterProvider' ] ;
10
+ routing . $inject = [ '$stateConfigProvider ' , '$urlRouterProvider' ] ;
11
11
12
- function routing ( $stateProvider , $urlRouterProvider ) {
12
+ function routing ( $stateConfigProvider , $urlRouterProvider ) {
13
13
14
14
// default route
15
15
$urlRouterProvider . otherwise ( '/' ) ;
16
16
17
17
// decorator: set reasonable defaults for entity.* routes
18
- $stateProvider . decorator ( 'views' , function ( state , parent ) {
18
+ $stateConfigProvider . decorator ( 'views' , function ( state , parent ) {
19
19
20
20
var config = state . self ;
21
21
34
34
} ) ;
35
35
36
36
// app routes
37
- $stateProvider
37
+ $stateConfigProvider
38
38
. state ( 'root' , {
39
39
url : '/' ,
40
40
redirectTo : {
Original file line number Diff line number Diff line change 45
45
< script src ="services/data.factory.js "> </ script >
46
46
< script src ="services/mapper.service.js "> </ script >
47
47
48
- <!-- Models -->
48
+ <!-- Custom Models -->
49
49
< script src ="models/artwork.service.js "> </ script >
50
50
< script src ="models/agent.service.js "> </ script >
51
51
52
+ <!-- Generic Models -->
53
+ < script src ="services/state-config.provider.js "> </ script >
54
+
52
55
<!-- States -->
53
56
< script src ="states/entity/entity.js "> </ script >
54
57
< script src ="states/entity/default.js "> </ script >
Original file line number Diff line number Diff line change
1
+ ( function ( ) {
2
+ 'use strict' ;
3
+
4
+ angular
5
+ . module ( 'app' )
6
+ . provider ( '$stateConfig' , Provider ) ;
7
+
8
+ // $state.get() allows us to check if a state exists,
9
+ // but there's no equivallent method for $stateProvider.
10
+ // https://github.com/angular-ui/ui-router/issues/265
11
+
12
+ // $stateConfigProvider stores the state's name,
13
+ // before deferring calls to $stateProvider.
14
+
15
+ // Use $stateConfigProvider.exists() to check if a state exists
16
+
17
+ Provider . $inject = [ '$stateProvider' ] ;
18
+
19
+ function Provider ( $stateProvider ) {
20
+
21
+ var states = [ ] ;
22
+
23
+ this . state = state ;
24
+ this . decorator = $stateProvider . decorator ;
25
+
26
+ this . exists = exists ;
27
+
28
+ this . $get = function ( ) {
29
+ return this ;
30
+ } ;
31
+
32
+ return this ;
33
+
34
+ function state ( name , data ) {
35
+
36
+ states . push ( name ) ;
37
+
38
+ $stateProvider . state . apply ( this , arguments ) ;
39
+
40
+ return this ;
41
+
42
+ }
43
+
44
+ function exists ( name ) {
45
+
46
+ return states . indexOf ( name ) > - 1 ;
47
+
48
+ }
49
+
50
+ }
51
+
52
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments