Deep Linking and State Transitions · Issue #200 · angular-ui/ui-router (original) (raw)

I'm trying to better understand how to effectively organize my code around the state transitions model presented by ui-router. I'm also new to Angular so please feel free to point out my mistakes.

It seems as though there are two general sources of state transitions:

By default, $stateProvider configuration takes care of updating the URL and changing the view to match the new state but any other application logic has to be handled separately.

It would make sense to put all that logic in the controller but I'm having a hard time understanding how to arrange for those implicit state transitions to trigger a controller function.

onEnter and onExit would seem to be the obvious 'hooks' but I'm not sure how to provide the correct $scope to those callbacks, they aren't injectable functions.

So what is the recommended way to react to state transitions triggered by deep links and/or URL edits by the user? Should I be putting all that logic in the controller or should it be somewhere else?