| @@ -4,11 +4,13 @@ import { NgModule } from '@angular/core'; | |||||
| import { AppComponent } from './app.component'; | import { AppComponent } from './app.component'; | ||||
| import { HeroesComponent } from './heroes/heroes.component'; | import { HeroesComponent } from './heroes/heroes.component'; | ||||
| import {FormsModule} from '@angular/forms'; | import {FormsModule} from '@angular/forms'; | ||||
| import { HeroDetailComponent } from './hero-detail/hero-detail.component'; | |||||
| @NgModule({ | @NgModule({ | ||||
| declarations: [ | declarations: [ | ||||
| AppComponent, | AppComponent, | ||||
| HeroesComponent | |||||
| HeroesComponent, | |||||
| HeroDetailComponent | |||||
| ], | ], | ||||
| imports: [ | imports: [ | ||||
| BrowserModule, | BrowserModule, | ||||
| @@ -0,0 +1,9 @@ | |||||
| <div *ngIf="hero"> | |||||
| <h2>{{hero.name | uppercase}} Details</h2> | |||||
| <div><span>id: </span>{{hero.id}}</div> | |||||
| <div> | |||||
| <label>name: | |||||
| <input [(ngModel)]="hero.name" placeholder="name"/> | |||||
| </label> | |||||
| </div> | |||||
| </div> | |||||
| @@ -0,0 +1,25 @@ | |||||
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { HeroDetailComponent } from './hero-detail.component'; | |||||
| describe('HeroDetailComponent', () => { | |||||
| let component: HeroDetailComponent; | |||||
| let fixture: ComponentFixture<HeroDetailComponent>; | |||||
| beforeEach(async(() => { | |||||
| TestBed.configureTestingModule({ | |||||
| declarations: [ HeroDetailComponent ] | |||||
| }) | |||||
| .compileComponents(); | |||||
| })); | |||||
| beforeEach(() => { | |||||
| fixture = TestBed.createComponent(HeroDetailComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,18 @@ | |||||
| import {Component, Input, OnInit} from '@angular/core'; | |||||
| import { Hero } from '../hero'; | |||||
| @Component({ | |||||
| selector: 'app-hero-detail', | |||||
| templateUrl: './hero-detail.component.html', | |||||
| styleUrls: ['./hero-detail.component.css'] | |||||
| }) | |||||
| export class HeroDetailComponent implements OnInit { | |||||
| @Input() hero: Hero; | |||||
| constructor() { } | |||||
| ngOnInit() { | |||||
| } | |||||
| } | |||||
| @@ -7,12 +7,4 @@ | |||||
| </li> | </li> | ||||
| </ul> | </ul> | ||||
| <div *ngIf="selectedHero"> | |||||
| <h2>{{selectedHero.name | uppercase}} Details</h2> | |||||
| <div><span>id: </span>{{selectedHero.id}}</div> | |||||
| <div> | |||||
| <label>name: | |||||
| <input [(ngModel)]="selectedHero.name" placeholder="name"/> | |||||
| </label> | |||||
| </div> | |||||
| </div> | |||||
| <app-hero-detail [hero]="selectedHero"></app-hero-detail> | |||||