1
- import { StateProvider } from '@uirouter/angularjs' ;
2
- import { Ng1StateDeclaration } from '@uirouter/angularjs/lib/interface' ;
3
- import { getTypeName , NgModule } from 'angular-ts-decorators' ;
1
+ import { NgModule } from 'angular-ts-decorators' ;
2
+ import { AppRoutingModule } from './app-routing.module' ;
4
3
import { AppComponent } from './app.component' ;
5
4
import { DashboardComponent } from './dashboard/dashboard.component' ;
6
5
import { HeroDetailComponent } from './hero-detail/hero-detail.component' ;
@@ -9,23 +8,12 @@ import { HeroService } from './hero.service';
9
8
import { HeroesComponent } from './heroes/heroes.component' ;
10
9
import { MessageService } from './message.service' ;
11
10
import { MessagesComponent } from './messages/messages.component' ;
12
-
13
11
import './styles.css' ;
14
12
15
- export interface UiState extends Ng1StateDeclaration {
16
- component ?: any ;
17
- }
18
-
19
- const routes : UiState [ ] = [
20
- { name : 'index' , url : '' , redirectTo : 'dashboard' } ,
21
- { name : 'dashboard' , url : '/dashboard' , component : DashboardComponent } ,
22
- { name : 'detail' , url : '/detail/{id}' , component : HeroDetailComponent } ,
23
- { name : 'heroes' , url : '/heroes' , component : HeroesComponent }
24
- ] ;
25
-
26
13
@NgModule ( {
14
+ id : 'AppModule' ,
27
15
imports : [
28
- 'ui.router'
16
+ AppRoutingModule
29
17
] ,
30
18
declarations : [
31
19
AppComponent ,
@@ -36,21 +24,9 @@ const routes: UiState[] = [
36
24
HeroSearchComponent
37
25
] ,
38
26
providers : [
39
- { provide : 'heroService' , useClass : HeroService } ,
40
- { provide : 'messageService' , useClass : MessageService }
27
+ HeroService ,
28
+ MessageService ,
41
29
] ,
42
30
bootstrap : [ AppComponent ]
43
31
} )
44
- export class AppModule {
45
- static config ( $stateProvider : StateProvider ) {
46
- 'ngInject' ;
47
- routes . forEach ( ( route ) => $stateProvider . state ( getNg1StateDeclaration ( route ) ) ) ;
48
- }
49
- }
50
-
51
- function getNg1StateDeclaration ( state : UiState ) {
52
- if ( state . component && typeof state . component !== 'string' ) {
53
- state . component = getTypeName ( state . component ) ;
54
- }
55
- return state ;
56
- }
32
+ export class AppModule { }
0 commit comments