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
|
// #docregion deleteHero
|
||||||
/** DELETE: delete the hero from the server */
|
/** DELETE: delete the hero from the server */
|
||||||
deleteHero(hero: Hero | number): Observable<Hero> {
|
deleteHero(id: number): Observable<Hero> {
|
||||||
const id = typeof hero === 'number' ? hero : hero.id;
|
|
||||||
const url = `${this.heroesUrl}/${id}`;
|
const url = `${this.heroesUrl}/${id}`;
|
||||||
|
|
||||||
return this.http.delete<Hero>(url, this.httpOptions).pipe(
|
return this.http.delete<Hero>(url, this.httpOptions).pipe(
|
||||||
|
@ -36,7 +36,7 @@ export class HeroesComponent implements OnInit {
|
|||||||
// #docregion delete
|
// #docregion delete
|
||||||
delete(hero: Hero): void {
|
delete(hero: Hero): void {
|
||||||
this.heroes = this.heroes.filter(h => h !== hero);
|
this.heroes = this.heroes.filter(h => h !== hero);
|
||||||
this.heroService.deleteHero(hero).subscribe();
|
this.heroService.deleteHero(hero.id).subscribe();
|
||||||
}
|
}
|
||||||
// #enddocregion delete
|
// #enddocregion delete
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user