Created
May 12, 2018 10:52
-
-
Save nerdic-coder/d8cd584b2b9d6f8abfdcaef0cef77fc2 to your computer and use it in GitHub Desktop.
addHero.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
handleChangeName(event) { | |
this.hero = { | |
id: this.hero.id, | |
name: event.target.value | |
}; | |
} | |
add(): void { | |
this.hero.name = this.hero.name.trim(); | |
if (!this.hero.name) { return; } | |
this.heroService.addHero(this.hero).subscribe(hero => { | |
this.heroes.push(hero); | |
this.hero = { | |
id: this.hero.id, | |
name: "" | |
}; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment