From 08e23c9ad4fad0c1fdd80479d75090d8a9e7f074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Thu, 29 Mar 2018 12:19:52 -0700 Subject: [PATCH] docs: change examples within services to be tree-shakeable --- aio/content/examples/toh-pt4/src/app/app.module.ts | 5 +---- aio/content/examples/toh-pt4/src/app/hero.service.1.ts | 2 +- aio/content/examples/toh-pt4/src/app/hero.service.ts | 2 +- aio/content/examples/toh-pt4/src/app/message.service.ts | 2 +- aio/content/examples/toh-pt5/src/app/app.module.ts | 3 --- aio/content/examples/toh-pt5/src/app/hero.service.ts | 2 +- aio/content/examples/toh-pt5/src/app/message.service.ts | 2 +- aio/content/examples/toh-pt6/src/app/app.module.ts | 3 --- aio/content/examples/toh-pt6/src/app/hero.service.ts | 2 +- aio/content/examples/toh-pt6/src/app/message.service.ts | 2 +- 10 files changed, 8 insertions(+), 17 deletions(-) diff --git a/aio/content/examples/toh-pt4/src/app/app.module.ts b/aio/content/examples/toh-pt4/src/app/app.module.ts index f3cc34faff9e2..95306bb2f3f6a 100644 --- a/aio/content/examples/toh-pt4/src/app/app.module.ts +++ b/aio/content/examples/toh-pt4/src/app/app.module.ts @@ -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 diff --git a/aio/content/examples/toh-pt4/src/app/hero.service.1.ts b/aio/content/examples/toh-pt4/src/app/hero.service.1.ts index 84f5eed9cee29..408dc3945b0a0 100644 --- a/aio/content/examples/toh-pt4/src/app/hero.service.1.ts +++ b/aio/content/examples/toh-pt4/src/app/hero.service.1.ts @@ -8,7 +8,7 @@ import { Hero } from './hero'; import { HEROES } from './mock-heroes'; // #docregion new -@Injectable() +@Injectable({providedIn: 'root'}) export class HeroService { constructor() { } diff --git a/aio/content/examples/toh-pt4/src/app/hero.service.ts b/aio/content/examples/toh-pt4/src/app/hero.service.ts index c93a3ff21556f..7e4e2ba30ccda 100644 --- a/aio/content/examples/toh-pt4/src/app/hero.service.ts +++ b/aio/content/examples/toh-pt4/src/app/hero.service.ts @@ -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 diff --git a/aio/content/examples/toh-pt4/src/app/message.service.ts b/aio/content/examples/toh-pt4/src/app/message.service.ts index 1c56a49e70aa1..30614a8af4f42 100644 --- a/aio/content/examples/toh-pt4/src/app/message.service.ts +++ b/aio/content/examples/toh-pt4/src/app/message.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class MessageService { messages: string[] = []; diff --git a/aio/content/examples/toh-pt5/src/app/app.module.ts b/aio/content/examples/toh-pt5/src/app/app.module.ts index 120bf48fcda9c..ba832f848f90f 100644 --- a/aio/content/examples/toh-pt5/src/app/app.module.ts +++ b/aio/content/examples/toh-pt5/src/app/app.module.ts @@ -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 }) diff --git a/aio/content/examples/toh-pt5/src/app/hero.service.ts b/aio/content/examples/toh-pt5/src/app/hero.service.ts index 8b90d0a2f045e..f0d6dc0a2868d 100644 --- a/aio/content/examples/toh-pt5/src/app/hero.service.ts +++ b/aio/content/examples/toh-pt5/src/app/hero.service.ts @@ -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) { } diff --git a/aio/content/examples/toh-pt5/src/app/message.service.ts b/aio/content/examples/toh-pt5/src/app/message.service.ts index 1c56a49e70aa1..30614a8af4f42 100644 --- a/aio/content/examples/toh-pt5/src/app/message.service.ts +++ b/aio/content/examples/toh-pt5/src/app/message.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class MessageService { messages: string[] = []; diff --git a/aio/content/examples/toh-pt6/src/app/app.module.ts b/aio/content/examples/toh-pt6/src/app/app.module.ts index a5734c50187db..9770300706b52 100644 --- a/aio/content/examples/toh-pt6/src/app/app.module.ts +++ b/aio/content/examples/toh-pt6/src/app/app.module.ts @@ -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 { } diff --git a/aio/content/examples/toh-pt6/src/app/hero.service.ts b/aio/content/examples/toh-pt6/src/app/hero.service.ts index b569c7052d10d..068da510b2971 100644 --- a/aio/content/examples/toh-pt6/src/app/hero.service.ts +++ b/aio/content/examples/toh-pt6/src/app/hero.service.ts @@ -19,7 +19,7 @@ const httpOptions = { }; // #enddocregion http-options -@Injectable() +@Injectable({ providedIn: 'root' }) export class HeroService { // #docregion heroesUrl diff --git a/aio/content/examples/toh-pt6/src/app/message.service.ts b/aio/content/examples/toh-pt6/src/app/message.service.ts index 1c56a49e70aa1..30614a8af4f42 100644 --- a/aio/content/examples/toh-pt6/src/app/message.service.ts +++ b/aio/content/examples/toh-pt6/src/app/message.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; -@Injectable() +@Injectable({ providedIn: 'root' }) export class MessageService { messages: string[] = [];