docs: change examples within services to be tree-shakeable (#23070)

PR Close #23070
This commit is contained in:
Matias Niemelä 2018-03-29 12:19:52 -07:00 committed by Alex Rickabaugh
parent 7ca772060b
commit 18ac228a27
10 changed files with 8 additions and 17 deletions

View File

@ -5,8 +5,6 @@ import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { HeroesComponent } from './heroes/heroes.component';
import { HeroDetailComponent } from './hero-detail/hero-detail.component';
import { HeroService } from './hero.service';
import { MessageService } from './message.service';
import { MessagesComponent } from './messages/messages.component';
@NgModule({
@ -23,9 +21,8 @@ import { MessagesComponent } from './messages/messages.component';
// #docregion providers
// #docregion providers-heroservice
providers: [
HeroService,
// #enddocregion providers-heroservice
MessageService
// no need to place any providers due to the `providedIn` flag...
// #docregion providers-heroservice
],
// #enddocregion providers-heroservice

View File

@ -8,7 +8,7 @@ import { Hero } from './hero';
import { HEROES } from './mock-heroes';
// #docregion new
@Injectable()
@Injectable({providedIn: 'root'})
export class HeroService {
constructor() { }

View File

@ -14,7 +14,7 @@ import { HEROES } from './mock-heroes';
import { MessageService } from './message.service';
// #enddocregion import-message-service
@Injectable()
@Injectable({ providedIn: 'root' })
export class HeroService {
// #docregion ctor

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
@Injectable()
@Injectable({ providedIn: 'root' })
export class MessageService {
messages: string[] = [];

View File

@ -7,8 +7,6 @@ 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 { HeroService } from './hero.service';
import { MessageService } from './message.service';
import { MessagesComponent } from './messages/messages.component';
// #docregion routing-module
@ -30,7 +28,6 @@ import { AppRoutingModule } from './app-routing.module';
MessagesComponent
],
// #enddocregion dashboard
providers: [ HeroService, MessageService ],
bootstrap: [ AppComponent ]
// #docregion routing-module
})

View File

@ -6,7 +6,7 @@ import { Hero } from './hero';
import { HEROES } from './mock-heroes';
import { MessageService } from './message.service';
@Injectable()
@Injectable({ providedIn: 'root' })
export class HeroService {
constructor(private messageService: MessageService) { }

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
@Injectable()
@Injectable({ providedIn: 'root' })
export class MessageService {
messages: string[] = [];

View File

@ -19,8 +19,6 @@ import { HeroesComponent } from './heroes/heroes.component';
// #enddocregion v1
import { HeroSearchComponent } from './hero-search/hero-search.component';
// #docregion v1
import { HeroService } from './hero.service';
import { MessageService } from './message.service';
import { MessagesComponent } from './messages/messages.component';
@NgModule({
@ -49,7 +47,6 @@ import { MessagesComponent } from './messages/messages.component';
HeroSearchComponent
// #docregion v1
],
providers: [ HeroService, MessageService ],
bootstrap: [ AppComponent ]
})
export class AppModule { }

View File

@ -19,7 +19,7 @@ const httpOptions = {
};
// #enddocregion http-options
@Injectable()
@Injectable({ providedIn: 'root' })
export class HeroService {
// #docregion heroesUrl

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
@Injectable()
@Injectable({ providedIn: 'root' })
export class MessageService {
messages: string[] = [];