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' ;
43import { AppComponent } from './app.component' ;
54import { DashboardComponent } from './dashboard/dashboard.component' ;
65import { HeroDetailComponent } from './hero-detail/hero-detail.component' ;
@@ -9,23 +8,12 @@ import { HeroService } from './hero.service';
98import { HeroesComponent } from './heroes/heroes.component' ;
109import { MessageService } from './message.service' ;
1110import { MessagesComponent } from './messages/messages.component' ;
12-
1311import './styles.css' ;
1412
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-
2613@NgModule ( {
14+ id : 'AppModule' ,
2715 imports : [
28- 'ui.router'
16+ AppRoutingModule
2917 ] ,
3018 declarations : [
3119 AppComponent ,
@@ -36,21 +24,9 @@ const routes: UiState[] = [
3624 HeroSearchComponent
3725 ] ,
3826 providers : [
39- { provide : 'heroService' , useClass : HeroService } ,
40- { provide : 'messageService' , useClass : MessageService }
27+ HeroService ,
28+ MessageService ,
4129 ] ,
4230 bootstrap : [ AppComponent ]
4331} )
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