Is there a way to bind a function to specific state name instead of the state change event?
For example, this is what I do now:
$scope.$on('$stateChangeSuccess', function(evt, toState, toParams, fromState, fromParams) {
console.log(toState.name);
});
Basically, I bind to $stateChangeSuccess
and get toState.name
to process a specific task. But I feel this is a bit overkill as it binds to a general event. I just want to bind to a specific state such as toState.name = "foo"
or something like that.
Any pointer?
Thanks.