So I'm working with the component based approach in angular, lets say I have A directive called <home></home>;
import template from './home.html';
import controller from './home.controller.js';
angular.module('myApp')
.directive('home', homeDirective);
let homeDirective = () => {
return {
restrict: 'E',
template,
controller,
controllerAs: 'vm',
bindToController: true
};
};
Now I'm able to use the component <home></home> in my routing as follow:
angular.module('myApp')
.config(($routeProvider) => {
$routeProvider.when('/', {
template: '<home></home>'
})
})
I really like this approach, but with the "old" approach I was used to using "resolve" in my routeconfig to render the component only when a promise was resolved:
angular.module('myApp')
.config(($routeProvider) => {
$routeProvider.when('/', {
templateUrl: './home.html',
controller: './home.controller.js',
resolve: {
message: function(messageService){
return messageService.getMessage();
}
})
})
Question
How can I use resolve with a component based approach in angular? aaj