Reputation: 519
How can I make a component route wait for a data befere to execute the controller and render the view. Similar to resolve
of ngRoute
and ui-router
.
The documentation has this:
This only wait for the url change, ex:
//Old url
http://localhost/#/
// wait the promise (eg 1s) and then change the url to
http://localhost/#/heroes
But the view was changed immediately after the click in link, and then the url was changed, so weird!
This don't block the view render or controller execution (obviously).
Demo of this situation:
Code and preview: plunkr.co (click in heroes)
There are a similiar question that has no answers: Angular 1.5.x Component Router Resolve
Upvotes: 0
Views: 179
Reputation: 519
This should be configured in the component definition:
.component('myComponent', {
templateUrl: './my-compnent.html',
controller: MyComponentCtrl,
$canActivate: function($nextInstruction, $prevInstruction) {
return Promise.resolve(<true or false>);
}
})
Upvotes: 2