Under certain circumstances, I would like to switch to the default state or "otherwise." Therefore, I need to get from the controller that otherwise the state is configured in the routing object.
When I try to enter $urlRouterProvidermy directives into the controller, I get an error message:
Error: [$ injector: unpr] Unknown provider: $ stateProviderProvider <- $ stateProvider <- bbvNavDirective
What am I doing wrong?
Code example:
.config([ '$stateProvider', '$urlRouterProvider', '$locationProvider', ( $stateProvider, $urlRouterProvider, $locationProvider ) => {
$locationProvider.html5Mode(true);
$urlRouterProvider.otherwise('/bbv/voorstellen/open');
(...routing code)
}])
Directive
.directive('bbvNav', [ '$state', ( $state ) => {
return {
restrict: 'E',
template,
scope: {
titleBind: '&',
onButtonClick: '&'
},
bindToController: true,
controller: [ '$scope', function ( $scope ) {
$state.go( <NAVIGATE TO URLROUTERPOVIDER.OTHERWISE> );
console.log('Accessing $urlRouterProvider.otherwise state:');
}
}
})
source
share