I'm building an angular app and I want to load my components only when that route has been requested. I thought something like this might work
const states = [{
name: 'login',
url: '/login?sessid',
component: 'login',
resolve: {
login: () => import('./components/login.js').then(login => {
login.default.register()
}),
},
}];
Where the login component is
export default {
register() {
angular.module('trending')
.component('login', () => ({
template: 'Hello!'
})
)
}
};
But I get an error
angular.js?10a4:13708 Error: [$injector:unpr] Unknown provider:
loginDirectiveProvider <- loginDirective
Presumably because the login component isn't registered before the state is. I realize that this is abusing the purpose of the resolve property, I just hoped it would work for my needs. What's a better way to fix this?