This commit updates the `tslint.json` configuration file, that is used to lint the docs examples, to match the one generated for new Angular CLI apps. There are some minimal differences (marked with `TODO` comments) for things, such as component selector prefix, that would require extensive and/or difficult to validate changes in guides. This commit also includes the final adjustments to make the docs examples code compatible with the new tslint rules. (The bulk of the work has been done in previous commits.) PR Close #38143
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
// #docplaster
|
|
import { NgModule } from '@angular/core';
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
import { FormsModule } from '@angular/forms';
|
|
import { HttpClientModule } from '@angular/common/http';
|
|
|
|
import { HttpClientInMemoryWebApiModule } from 'angular-in-memory-web-api';
|
|
import { InMemoryDataService } from './in-memory-data.service';
|
|
|
|
import { AppRoutingModule } from './app-routing.module';
|
|
|
|
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';
|
|
|
|
// #docregion platform-detection
|
|
import { PLATFORM_ID, APP_ID, Inject } from '@angular/core';
|
|
import { isPlatformBrowser } from '@angular/common';
|
|
|
|
// #enddocregion platform-detection
|
|
|
|
@NgModule({
|
|
imports: [
|
|
// #docregion browsermodule
|
|
BrowserModule.withServerTransition({ appId: 'tour-of-heroes' }),
|
|
// #enddocregion browsermodule
|
|
FormsModule,
|
|
AppRoutingModule,
|
|
HttpClientModule,
|
|
|
|
// The HttpClientInMemoryWebApiModule module intercepts HTTP requests
|
|
// and returns simulated server responses.
|
|
// Remove it when a real server is ready to receive requests.
|
|
HttpClientInMemoryWebApiModule.forRoot(
|
|
InMemoryDataService, { dataEncapsulation: false }
|
|
)
|
|
],
|
|
declarations: [
|
|
AppComponent,
|
|
DashboardComponent,
|
|
HeroesComponent,
|
|
HeroDetailComponent,
|
|
MessagesComponent,
|
|
HeroSearchComponent
|
|
],
|
|
bootstrap: [ AppComponent ]
|
|
})
|
|
export class AppModule {
|
|
// #docregion platform-detection
|
|
constructor(
|
|
@Inject(PLATFORM_ID) private platformId: object,
|
|
@Inject(APP_ID) private appId: string) {
|
|
const platform = isPlatformBrowser(platformId) ?
|
|
'in the browser' : 'on the server';
|
|
console.log(`Running ${platform} with appId=${appId}`);
|
|
}
|
|
// #enddocregion platform-detection
|
|
}
|