Skip to content

Instantly share code, notes, and snippets.

@latish
Created January 21, 2019 22:31
Show Gist options
  • Save latish/fece4e0828587f254d0088f3e5027033 to your computer and use it in GitHub Desktop.
Save latish/fece4e0828587f254d0088f3e5027033 to your computer and use it in GitHub Desktop.
<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>
<button (click)="goBackClicked()">go back</button>
<button (click)="saveClicked()">save</button>
</div>
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Hero } from '../hero';
@Component({
selector: 'app-hero-detail-ui',
templateUrl: './hero-detail.component.html',
styleUrls: [ './hero-detail.component.css' ]
})
export class HeroDetailComponent {
@Input() hero: Hero;
@Output() goBack= new EventEmitter();
@Output() save= new EventEmitter<Hero>();
goBackClicked(): void {
this.goBack.emit();
}
saveClicked(): void {
this.save.emit(this.hero);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment