I am trying to access $ routeProvider in one of my controllers to add a route. How to do it?
function Cont($scope,$routeProvider) { };
This does not work for me; I get:Error: Unknown provider: $routeProviderProvider <- $routeProvider
Error: Unknown provider: $routeProviderProvider <- $routeProvider
$ routeProvider and other providers can only be entered in the module configuration block. What do you want to do with $ routeProvider inside the controller?
$ Route is available in the controller, but $ routeProvider is not. Perhaps you can just copy the function, for example, "when" and "pathRegExp"
See jsfiddle: http://jsfiddle.net/5FUQa/1/
function addRoute(path, route) { //slightly modified 'when' function in angular-route.js } addRoute('/dynamic', { templateUrl: 'dynamic.tpl.html' });
Also see: How to defer route determination in Angular.js?