docs: simplify deleteHero method in tutorial (#41303)

Fixes #41233

PR Close #41303
This commit is contained in:
MariosRadis 2021-03-21 17:21:44 +02:00 committed by Misko Hevery
parent 5eb7f3491f
commit ed5bfe8173
2 changed files with 2 additions and 3 deletions

View File

@ -104,8 +104,7 @@ export class HeroService {
// #docregion deleteHero
/** DELETE: delete the hero from the server */
deleteHero(hero: Hero | number): Observable<Hero> {
const id = typeof hero === 'number' ? hero : hero.id;
deleteHero(id: number): Observable<Hero> {
const url = `${this.heroesUrl}/${id}`;
return this.http.delete<Hero>(url, this.httpOptions).pipe(

View File

@ -36,7 +36,7 @@ export class HeroesComponent implements OnInit {
// #docregion delete
delete(hero: Hero): void {
this.heroes = this.heroes.filter(h => h !== hero);
this.heroService.deleteHero(hero).subscribe();
this.heroService.deleteHero(hero.id).subscribe();
}
// #enddocregion delete