Monday, March 26, 2018

Difference between snapshot and subscribe of ActivatedRoute.

snapshot used when there is only one redirection on same component. If there is multiple redirection  than snapshot will not work. In that case subscription will be good.

Suppose you can component which is showing three product

Samsung
Nokia
iPhone

on click of each product use ou have used route.Navigation which redirect to show the detail in below portion of page.
on first click the instance of detail component created so constructor invoked, and in second click insatnce of detail component will not be created since it is already exist, so constructor will not be invoked. In that case snapshot property will be useless.

Source : https://yakovfain.com/2016/11/20/angular-2-implementing-master-detail-using-router/

No comments:

Followers

Link