First of all, .subscribe is not an Angular2 thing. That's a method that comes from rxjs library which Angular is using behind the scene. If you can imagine yourself when subscribing to a newsletter and after the subscribing, every time that there is a new newsletter, they will send it to your home ( the method inside subscribe get's called). That's what happens when you subscribing to a source of magazines ( which they call it Observable in rxjs library) All the AJAX calls in Angular is using this library behind the scene and in order to use any of them, you've got to use the method name, e.g get, and then call subscribe on it, because get returns and Observable. Also, when you're doing this Angular is using Observables behind the scene and subscribes you to that source of thing, which in this case is a click event. Back to our analogy of Observables and newsletter stores, after you've subscribed, as soon as and as long as there is a new magazine, they'll send it to you unless you go and unsubscribe from them which for that to happen you've got to remember the subscription number or id, which in rxjs it would be like : let subscription = magazineStore.getMagazines().subscribe( (newMagazine)=>{ console.log('newMagazine',newMagazine); }); And when you don't want to get the magazines anymore: subscription.unsubscribe(); Also, the same goes for this.route.paramMap which is returning an Observable and then you're subscribing to it. My personal view is rxjs was one of the greatest things that were brought to JavaScript world and it's even better in Angular. There are 150~ rxjs methods ( very similar to lodash methods) and the one that you're using is called switchMap
Hi Deepak,In Angular we are using subscribe within component for getting the data from API through angular service as below :this.testService.get('yourl') {.subscribe(async testmodel => {this.testmodel = await testmodel } error => console.log('If error', error));As you can see above I am calling the service and getting the data asynchronously using subscribe.Hope Its help you.