2017-04-01 01:57:13 +02:00
|
|
|
// #docplaster
|
2020-07-30 13:03:09 +03:00
|
|
|
import { NgModule } from '@angular/core';
|
|
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
import { FormsModule } from '@angular/forms';
|
|
|
|
import { HttpClientModule } from '@angular/common/http';
|
2017-04-01 01:57:13 +02:00
|
|
|
|
2017-08-15 10:22:55 -07:00
|
|
|
import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
|
2020-07-30 13:03:09 +03:00
|
|
|
import { InMemoryDataService } from './in-memory-data.service';
|
2017-10-30 23:39:58 +01:00
|
|
|
|
2020-07-30 13:03:09 +03:00
|
|
|
import { AppRoutingModule } from './app-routing.module';
|
2017-04-01 01:57:13 +02:00
|
|
|
|
2020-07-30 13:03:09 +03:00
|
|
|
import { AppComponent } from './app.component';
|
|
|
|
import { DashboardComponent } from './dashboard/dashboard.component';
|
|
|
|
import { HeroDetailComponent } from './hero-detail/hero-detail.component';
|
|
|
|
import { HeroesComponent } from './heroes/heroes.component';
|
|
|
|
import { HeroSearchComponent } from './hero-search/hero-search.component';
|
|
|
|
import { MessagesComponent } from './messages/messages.component';
|
2017-04-01 01:57:13 +02:00
|
|
|
|
2017-08-15 10:22:55 -07:00
|
|
|
// #docregion platform-detection
|
|
|
|
import { PLATFORM_ID, APP_ID, Inject } from '@angular/core';
|
|
|
|
import { isPlatformBrowser } from '@angular/common';
|
|
|
|
|
|
|
|
// #enddocregion platform-detection
|
2017-10-30 23:39:58 +01:00
|
|
|
|
2017-04-01 01:57:13 +02:00
|
|
|
@NgModule({
|
|
|
|
imports: [
|
2017-08-15 10:22:55 -07:00
|
|
|
// #docregion browsermodule
|
2017-10-30 23:39:58 +01:00
|
|
|
BrowserModule.withServerTransition({ appId: 'tour-of-heroes' }),
|
2017-08-15 10:22:55 -07:00
|
|
|
// #enddocregion browsermodule
|
2017-04-01 01:57:13 +02:00
|
|
|
FormsModule,
|
2017-10-30 23:39:58 +01:00
|
|
|
AppRoutingModule,
|
2017-08-15 10:22:55 -07:00
|
|
|
HttpClientModule,
|
2020-04-15 13:46:50 +03:00
|
|
|
|
|
|
|
// The HttpClientInMemoryWebApiModule module intercepts HTTP requests
|
|
|
|
// and returns simulated server responses.
|
|
|
|
// Remove it when a real server is ready to receive requests.
|
2017-10-30 23:39:58 +01:00
|
|
|
HttpClientInMemoryWebApiModule.forRoot(
|
|
|
|
InMemoryDataService, { dataEncapsulation: false }
|
|
|
|
)
|
2017-04-01 01:57:13 +02:00
|
|
|
],
|
|
|
|
declarations: [
|
|
|
|
AppComponent,
|
|
|
|
DashboardComponent,
|
|
|
|
HeroesComponent,
|
2017-10-30 23:39:58 +01:00
|
|
|
HeroDetailComponent,
|
|
|
|
MessagesComponent,
|
2017-04-01 01:57:13 +02:00
|
|
|
HeroSearchComponent
|
|
|
|
],
|
|
|
|
bootstrap: [ AppComponent ]
|
|
|
|
})
|
2017-08-15 10:22:55 -07:00
|
|
|
export class AppModule {
|
2017-10-30 23:39:58 +01:00
|
|
|
// #docregion platform-detection
|
|
|
|
constructor(
|
2017-08-15 10:22:55 -07:00
|
|
|
@Inject(PLATFORM_ID) private platformId: Object,
|
|
|
|
@Inject(APP_ID) private appId: string) {
|
|
|
|
const platform = isPlatformBrowser(platformId) ?
|
2018-01-26 06:51:09 +01:00
|
|
|
'in the browser' : 'on the server';
|
2017-08-15 10:22:55 -07:00
|
|
|
console.log(`Running ${platform} with appId=${appId}`);
|
|
|
|
}
|
2017-10-30 23:39:58 +01:00
|
|
|
// #enddocregion platform-detection
|
2017-08-15 10:22:55 -07:00
|
|
|
}
|