Reputation: 6020
I want to be able to direct each user to different views depending on the user's data. For instance, if the user has not confirmed their email they should see a page asking them to do so. If a user is admin, they can see more things. I have not found anything from the documentation online. Anyone have ideas on this one?
For reference, I have experience with Iron-Router, which conveniently includes onBefore
hooks. However, I am not using Iron-Router for this case. Would be nice if something similar exists with Angular's UI-Router.
Upvotes: 0
Views: 3378
Reputation: 9993
UI-Router has 2 options for you:
1. Resolve parameter
You can use resolve to provide your controller with content or data that is custom to the state. resolve is an optional map of dependencies which should be injected into the controller.
Commonly used for getting data that will be used in controllers.
2. onEnter (https://github.com/angular-ui/ui-router/wiki/Quick-Reference)
Callback functions for when a state is entered and exited. Good way to trigger an action or dispatch an event, such as opening a dialog.
Upvotes: 2