| @@ -1 +1,2 @@ | |||||
| <h1>{{ title }}</h1> | |||||
| <h1>{{title}}</h1> | |||||
| <app-heroes></app-heroes> | |||||
| @@ -2,13 +2,17 @@ import { BrowserModule } from '@angular/platform-browser'; | |||||
| import { NgModule } from '@angular/core'; | import { NgModule } from '@angular/core'; | ||||
| import { AppComponent } from './app.component'; | import { AppComponent } from './app.component'; | ||||
| import { HeroesComponent } from './heroes/heroes.component'; | |||||
| import {FormsModule} from '@angular/forms'; | |||||
| @NgModule({ | @NgModule({ | ||||
| declarations: [ | declarations: [ | ||||
| AppComponent | |||||
| AppComponent, | |||||
| HeroesComponent | |||||
| ], | ], | ||||
| imports: [ | imports: [ | ||||
| BrowserModule | |||||
| BrowserModule, | |||||
| FormsModule | |||||
| ], | ], | ||||
| providers: [], | providers: [], | ||||
| bootstrap: [AppComponent] | bootstrap: [AppComponent] | ||||
| @@ -0,0 +1,4 @@ | |||||
| export class Hero { | |||||
| id: number; | |||||
| name: string; | |||||
| } | |||||
| @@ -0,0 +1,7 @@ | |||||
| <h2>{{hero.name | uppercase}} Details</h2> | |||||
| <div><span>id: </span>{{hero.id}}</div> | |||||
| <div> | |||||
| <label>name: | |||||
| <input [(ngModel)]="hero.name" placeholder="name"/> | |||||
| </label> | |||||
| </div> | |||||
| @@ -0,0 +1,25 @@ | |||||
| import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { HeroesComponent } from './heroes.component'; | |||||
| describe('HeroesComponent', () => { | |||||
| let component: HeroesComponent; | |||||
| let fixture: ComponentFixture<HeroesComponent>; | |||||
| beforeEach(async(() => { | |||||
| TestBed.configureTestingModule({ | |||||
| declarations: [ HeroesComponent ] | |||||
| }) | |||||
| .compileComponents(); | |||||
| })); | |||||
| beforeEach(() => { | |||||
| fixture = TestBed.createComponent(HeroesComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,21 @@ | |||||
| import { Component, OnInit } from '@angular/core'; | |||||
| import {Hero} from './hero'; | |||||
| @Component({ | |||||
| selector: 'app-heroes', | |||||
| templateUrl: './heroes.component.html', | |||||
| styleUrls: ['./heroes.component.css'] | |||||
| }) | |||||
| export class HeroesComponent implements OnInit { | |||||
| hero: Hero = { | |||||
| id: 1, | |||||
| name: 'Windstorm' | |||||
| }; | |||||
| constructor() { } | |||||
| ngOnInit() { | |||||
| } | |||||
| } | |||||