
committed by
Igor Minar

parent
344a5ca545
commit
9bbf009dff
@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<label><input type="checkbox" [checked]="showHeroes" (change)="showHeroes=!showHeroes">Heroes</label>
|
||||
<label><input type="checkbox" [checked]="showVillains" (change)="showVillains=!showVillains">Villains</label>
|
||||
@ -9,9 +9,9 @@ import { Component } from '@angular/core';
|
||||
|
||||
<h1>Hierarchical Dependency Injection</h1>
|
||||
|
||||
<heroes-list *ngIf="showHeroes"></heroes-list>
|
||||
<villains-list *ngIf="showVillains"></villains-list>
|
||||
<my-cars *ngIf="showCars"></my-cars>
|
||||
<app-heroes-list *ngIf="showHeroes"></app-heroes-list>
|
||||
<app-villains-list *ngIf="showVillains"></app-villains-list>
|
||||
<app-cars *ngIf="showCars"></app-cars>
|
||||
`
|
||||
})
|
||||
export class AppComponent {
|
||||
|
@ -54,7 +54,7 @@ export class ACarComponent {
|
||||
}
|
||||
////////// CarsComponent ////////////
|
||||
@Component({
|
||||
selector: 'my-cars',
|
||||
selector: 'app-cars',
|
||||
template: `
|
||||
<h3>Cars</h3>
|
||||
<a-car></a-car>`
|
||||
|
@ -4,7 +4,7 @@ import { HeroTaxReturn } from './hero';
|
||||
import { HeroTaxReturnService } from './hero-tax-return.service';
|
||||
|
||||
@Component({
|
||||
selector: 'hero-tax-return',
|
||||
selector: 'app-hero-tax-return',
|
||||
templateUrl: './hero-tax-return.component.html',
|
||||
styleUrls: [ './hero-tax-return.component.css' ],
|
||||
// #docregion providers
|
||||
|
@ -6,7 +6,7 @@ import { Hero, HeroTaxReturn } from './hero';
|
||||
import { HeroesService } from './heroes.service';
|
||||
|
||||
@Component({
|
||||
selector: 'heroes-list',
|
||||
selector: 'app-heroes-list',
|
||||
template: `
|
||||
<div>
|
||||
<h3>Hero Tax Returns</h3>
|
||||
@ -15,11 +15,11 @@ import { HeroesService } from './heroes.service';
|
||||
(click)="showTaxReturn(hero)">{{hero.name}}
|
||||
</li>
|
||||
</ul>
|
||||
<hero-tax-return
|
||||
<app-hero-tax-return
|
||||
*ngFor="let selected of selectedTaxReturns; let i = index"
|
||||
[taxReturn]="selected"
|
||||
(close)="closeTaxReturn(i)">
|
||||
</hero-tax-return>
|
||||
</app-hero-tax-return>
|
||||
</div>
|
||||
`,
|
||||
styles: [ 'li {cursor: pointer;}' ]
|
||||
|
@ -6,7 +6,7 @@ import { Villain, VillainsService } from './villains.service';
|
||||
|
||||
// #docregion metadata
|
||||
@Component({
|
||||
selector: 'villains-list',
|
||||
selector: 'app-villains-list',
|
||||
templateUrl: './villains-list.component.html',
|
||||
providers: [ VillainsService ]
|
||||
})
|
||||
|
@ -1,26 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Hierarchical Injectors</title>
|
||||
<base href="/">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
|
||||
<!-- Polyfills -->
|
||||
<script src="node_modules/core-js/client/shim.min.js"></script>
|
||||
|
||||
<script src="node_modules/zone.js/dist/zone.js"></script>
|
||||
<script src="node_modules/systemjs/dist/system.src.js"></script>
|
||||
|
||||
<script src="systemjs.config.js"></script>
|
||||
<script>
|
||||
System.import('main.js').catch(function(err){ console.error(err); });
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<my-app>loading...</my-app>
|
||||
<app-root></app-root>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -1,5 +1,12 @@
|
||||
// #docregion
|
||||
import { enableProdMode } from '@angular/core';
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
import { environment } from './environments/environment';
|
||||
|
||||
if (environment.production) {
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule);
|
||||
|
Reference in New Issue
Block a user