-
Notifications
You must be signed in to change notification settings - Fork 131
What is the resolve equivalent in the new router?Β #100
Description
I read the source code and also the existing documentation you wrote for the router. Since I try to also sort of compare the old with the new router in the article, I need to explain the resolve $routeProvider config equivalent of the new router.
As far as I understand, instead of having this resolve block, we use canActivate and activate for it. Am I getting this right?
Whereas canActivate decides with the routing happens at all, activate is in charge of doing all the work that is needed to make needed data available in the controller. As you show in the docs, this could be something like:
MyController.prototype.activate = function() {
return this.bigFiles = this.$http.downloadBigFiles();
};this.bigFiles is what we usually would request in a resolve block. Please correct me if I'm wrong.
However, I still wonder how this behaves, if we have asynchronous work todo (actually the example looks asynchronous too). In the old router, resolve properties were injected into the controller that is associated to the view.
I understand that we don't need that anymore, as long as we just expose data on this (in the example this.bigFiles), since controller methods can just access it. But what if we have a promise, that needs to resolve first? Is that functionality also (still) supported in the new router?
Hope my question is clear.