-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Dependency Injection guides for CLI
- Loading branch information
Showing
24 changed files
with
608 additions
and
833 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
aio/content/examples/dependency-injection/src/app/app-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
Must put this interface in its own file instead of app.config.ts | ||
or else TypeScript gives a (bogus) warning: | ||
WARNING in ./src/app/... .ts | ||
"export 'AppConfig' was not found in './app.config' | ||
*/ | ||
export interface AppConfig { | ||
apiEndpoint: string; | ||
title: string; | ||
} |
4 changes: 1 addition & 3 deletions
4
aio/content/examples/dependency-injection/src/app/app.component.1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 4 additions & 6 deletions
10
aio/content/examples/dependency-injection/src/app/app.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
aio/content/examples/dependency-injection/src/app/dummy.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
/// Dummy modules to satisfy Angular Language Service | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { AppModule } from './app.module'; | ||
|
||
//////// | ||
|
||
import { AppComponent as AppComponent1 } from './app.component.1'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule, AppModule ], | ||
declarations: [ AppComponent1 ] | ||
}) | ||
export class DummyModule1 {} | ||
|
||
///////// | ||
|
||
import { AppComponent as AppComponent2 } from './app.component.2'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule, AppModule ], | ||
declarations: [ AppComponent2 ] | ||
}) | ||
export class DummyModule2 {} |
35 changes: 35 additions & 0 deletions
35
aio/content/examples/dependency-injection/src/app/heroes/dummy.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
/// Dummy modules to satisfy Angular Language Service | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
//////// | ||
|
||
import { HeroListComponent as HeroListComponent1 } from './hero-list.component.1'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule ], | ||
declarations: [ HeroListComponent1 ], | ||
exports: [ HeroListComponent1 ] | ||
}) | ||
export class DummyModule1 {} | ||
|
||
///////// | ||
|
||
import { HeroListComponent as HeroListComponent2 } from './hero-list.component.2'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule ], | ||
declarations: [ HeroListComponent2 ] | ||
}) | ||
export class DummyModule2 {} | ||
|
||
///////// | ||
|
||
import { HeroesComponent as HeroesComponent1 } from './heroes.component.1'; | ||
|
||
@NgModule({ | ||
imports: [ CommonModule, DummyModule1 ], | ||
declarations: [ HeroesComponent1 ] | ||
}) | ||
export class DummyModule3 {} |
9 changes: 5 additions & 4 deletions
9
aio/content/examples/dependency-injection/src/app/heroes/hero-list.component.1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
// #docregion | ||
import { Component } from '@angular/core'; | ||
|
||
import { HEROES } from './mock-heroes'; | ||
|
||
@Component({ | ||
selector: 'app-hero-list', | ||
template: ` | ||
<div *ngFor="let hero of heroes"> | ||
{{hero.id}} - {{hero.name}} | ||
</div> | ||
<div *ngFor="let hero of heroes"> | ||
{{hero.id}} - {{hero.name}} | ||
</div> | ||
` | ||
}) | ||
// #docregion class | ||
export class HeroListComponent { | ||
heroes = HEROES; | ||
} | ||
// #enddocregion class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
aio/content/examples/dependency-injection/src/app/heroes/hero-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
aio/content/examples/dependency-injection/src/app/heroes/hero.service.0.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable() | ||
export class HeroService { | ||
constructor() { } | ||
} |
1 change: 0 additions & 1 deletion
1
aio/content/examples/dependency-injection/src/app/heroes/hero.service.1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// #docregion | ||
import { Injectable } from '@angular/core'; | ||
|
||
import { HEROES } from './mock-heroes'; | ||
|
||
@Injectable() | ||
|
1 change: 0 additions & 1 deletion
1
aio/content/examples/dependency-injection/src/app/heroes/hero.service.2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
aio/content/examples/dependency-injection/src/app/heroes/hero.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 7 additions & 10 deletions
17
aio/content/examples/dependency-injection/src/app/heroes/heroes.component.1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
// #docplaster | ||
// #docregion full, v1 | ||
import { Component } from '@angular/core'; | ||
// #docregion, v1 | ||
import { Component } from '@angular/core'; | ||
// #enddocregion v1 | ||
import { HeroService } from './hero.service'; | ||
|
||
import { HeroService } from './hero.service'; | ||
// #enddocregion full | ||
|
||
// #docregion full, v1 | ||
|
||
// #docregion v1 | ||
@Component({ | ||
selector: 'app-heroes', | ||
// #enddocregion v1 | ||
providers: [HeroService], | ||
providers: [ HeroService ], | ||
// #docregion v1 | ||
template: ` | ||
<h2>Heroes</h2> | ||
<app-hero-list></app-hero-list> | ||
<h2>Heroes</h2> | ||
<app-hero-list></app-hero-list> | ||
` | ||
}) | ||
export class HeroesComponent { } |
9 changes: 4 additions & 5 deletions
9
aio/content/examples/dependency-injection/src/app/heroes/heroes.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
// #docregion | ||
import { Component } from '@angular/core'; | ||
|
||
import { heroServiceProvider } from './hero.service.provider'; | ||
|
||
@Component({ | ||
selector: 'app-heroes', | ||
providers: [ heroServiceProvider ], | ||
template: ` | ||
<h2>Heroes</h2> | ||
<app-hero-list></app-hero-list> | ||
`, | ||
providers: [heroServiceProvider] | ||
<h2>Heroes</h2> | ||
<app-hero-list></app-hero-list> | ||
` | ||
}) | ||
export class HeroesComponent { } |
Oops, something went wrong.