Is it possible to dynamically add Angular's resolve
after it has been initially defined in the app? Let's say we have a setup with routes like this:
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when("/", {templateUrl: "partials/home.html", controller: "PageCtrl"})
.when("/services", {templateUrl: "partials/services.html", controller: "PageCtrl"})
}]);
Now, at a later stage, can I modify specific route(s) to include resolve
for handling promises?
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when("/services", {
templateUrl: "partials/services.html",
controller: "PageCtrl",
resolve:{ getData: function(myService) { return myService.getOffer(); }}
})
}]);
I'm wondering how this can be achieved. The main challenge is adding this functionality after the initial configuration has taken place. It needs to happen sometime in the future.