I would like to know what are the best practices with regard to resolving data when using the Angular2 Router.
I typically work in systems where security is paramount to performance and I would typically block the route change if the authenticated user was not authorized to access a specific record e.g. a Contact.
So, I would lean toward creating a DetailResolveService that implements Resolve (imported from @angular/router) and then configure that DetailResolveService in the mymodule.routes.ts file to be resolved prior to the route change to display the Detail of a single record e.g. a single Contact record.
Your tutorial shows illustrates the use of pulling the Contact's ID off of the route params in the constructor and then beginning the resolve process for the Contact data based on that ID.
I have also seen plenty of examples of developers resolving data within the ngOnInit() method by implementing the ngOnInit "interface?" / lifecycle hook.
What is your best practice recommendation for those of us looking for the best way to resolve data in a DRY manner.
Should we encapsulate the resolving of an Observable HTTP call in the constructor prior to ngOnInit()?
Should we encapsulate the resolving of an Observable HTTP call in an ngOnInit()?
Should we encapsulate the resolving of an Observable HTTP call in a ResolveService that is configured to be called by the angular router prior to a route change and then assign the resolved data off of the this.activatedRoute.data?