docs: simplify deleteHero method in tutorial (#41303)
Fixes #41233 PR Close #41303
This commit is contained in:
parent
5eb7f3491f
commit
ed5bfe8173
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue