Reputation: 300
I can inject $urlProvider
in module.config()
but when i try to do it in module.controller()
I am getting this error:
Unknown provider: $urlRouterProviderProvider <- $urlRouterProvider <- MyCtrl
I have included angular-ui
, also imported ui.router
in the module.
I cannot see anybody doing this online, but why should it not work?
Upvotes: 1
Views: 422
Reputation: 32624
Providers are meant to be configured in the config phase, and then they can be injected into a controller
, or the run
phase, sans the Provider
post-fix:
app.config(function($urlRouterProvider) {
$urlRouterProvider.deferIntercept();
});
app.run('MyCtrl', function($urlRouter) { // no Provider post-fix
$urlRouter.listen();
});
See the Angular docs on Providers and the UI-Router's guide on $urlRouterProvider
for more information.
Upvotes: 2