finally suscribe typescript

Solutions on MaxInterview for finally suscribe typescript by the best coders in the world

showing results for - "finally suscribe typescript"
Lilli
02 Oct 2019
1So the subscribe function takes three parameters:
2onNext
3onError
4onCompleted
5
6this._heroService.addHero(this.hero).subscribe(
7      hero=> this.hero= hero,
8      error => console.log("Error: ", error),
9      function(){ this._router.navigate(['HeroDetail', { id: this.hero.id }]) }
10    );
11
12or 
13
14this._heroService.addHero(this.hero).subscribe({
15	next: event => { console.log(event) }, 
16  	error: error => { console.log(error) }, 
17   	complete: () => { console.log('complete') }
18});
19