app.module.ts 1.32 KB
import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';

//Http Service
import { HttpModule }    from '@angular/http';

import { AppComponent }  from './app.component';
import { HeroDetailComponent }  from './hero-detail/hero-detail.component';

// Imports for loading & configuring the in-memory web api
import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
import { InMemoryDataService }  from './services/mocks/in-memory-data.service';

//Routing
import { RouterModule }   from '@angular/router';

@NgModule({
  imports:      [ BrowserModule ,
  //Http Service
  HttpModule,
  FormsModule,
  RouterModule.forRoot([
                      { path: 'home', component: AppComponent},
                      // { path: 'detail', component: HeroDetailComponent} ,
                      { path: 'detail/:id', component: HeroDetailComponent} //Parameterized route
                    ]),
   InMemoryWebApiModule.forRoot(
                    InMemoryDataService
                    ,{ passThruUnknownUrl: true} //this will use the normal XHRBackend if the collection in the mock data can't be found
                  )],
  declarations: [ AppComponent,
        HeroDetailComponent ],
  bootstrap:    [ AppComponent ]
  
})
export class AppModule { }