$routeProvider
is a service of module ngRoute
that has a simple API, accepting either the when()
method which takes a path and hash of options including the templatePath
and controller
, which matches a pattern and otherwise()
method which allows us to redirect to a route if one is not found.
Questions tagged [route-provider]
299 questions
48
votes
5 answers
Turn off URL manipulation in AngularJS
I'm trying to write my first web-app with Angular.
In the normal mode (html5Mode off), Angular forces the address's hash part to look like a "path" (adding a leading "/"), and encodes special characters - for example, it allows a single "?" and "#"…

Oren
- 2,767
- 3
- 25
- 37
21
votes
2 answers
AngularJS - use routeProvider "when" variables to construct templateUrl name?
So this is what I am trying to accomplish:
'use strict';
var app = angular.module('myModule', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider
.when('/', {
redirectTo: '/pages'
})
.when('/pages/:pageName', {
…

Georgi Angelov
- 4,338
- 12
- 67
- 96
20
votes
3 answers
Using resolve in $routeProvider causes 'Unknown provider ...'
I am trying to do an asynchronous http request to load some data before my app loads and so I am using a resolve in $routeProvider which is an http request in my MainController. For some reason, I keep getting Error: [$injector:unpr] Unknown…

Georgi Angelov
- 4,338
- 12
- 67
- 96
14
votes
2 answers
Angularjs routing not working
Everything worked fine until I tried to add routing. I read that Angularjs version 1.2+ requires 'ngRoute' as an dependency (I am using version 1.2.16). I added it but it still doesn't work. Below are my codes.
test.html (Main Page)

yellowbyte
- 189
- 1
- 2
- 13
13
votes
1 answer
$routeProvider: templateUrl requests with X-Requested-With header
jQuery.ajax() normally sends an X-Requested-With header with XMLHttpRequest set as the content. On the server (in PHP), I usually detect this by testing:
$is_ajax = $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest'
In AngularJS, commonly found…

tester
- 22,441
- 25
- 88
- 128
10
votes
3 answers
Angular $routeParams force variable type
In my Angular app, I have routes like /items/:id
$routeProvider
.when('/items/:id', {
templateUrl: 'views/items.html',
controller: 'ItemCtrl'
})
In ItemCtrl I get :id with $routeParams.parcId The problem is it's a string while…

Tib
- 2,553
- 1
- 27
- 46
9
votes
2 answers
Access routeProvider's route properties
For a route defined like this:
$routeProvider
.when('/',
{
templateUrl:'views/login.html',
controller:'Login',
private:false
});
How can I access the private property inside a $routeChangeStart event for example?
Currently I'm using…

Francisc
- 77,430
- 63
- 180
- 276
6
votes
2 answers
Resolving multiple promises in routeprovider
So I wanted to execute 2 http calls to get some groups and questions from my server and have both of these resolved in routeprovider so that the corresponding controller will not load before I have the relevant data.
In my other controllers I always…

Robin-Hoodie
- 4,886
- 4
- 30
- 63
5
votes
3 answers
ng-view won't display template
I have been working a bit with Angular and I tried to implement simple routing.
I have a basic HTML which contains reference to all the required scripts and a ng-view tag.
For some reason, when the page is loaded, the template isn't shown in the…

Guy Tabak
- 53
- 4
5
votes
3 answers
no index.html after reloading angular app
I have an angular.js application with a basic setup like: My index.html renders the static stuff like Top/Sidebar. Inside I have to show the partial html files like for example my home.html
After I log into my application the…

Markus
- 1,565
- 6
- 26
- 57
5
votes
1 answer
AngularJs $routeProvider: using the redirectTo to redirect if a condition is met
I have these routes:
$routeProvider.when('/events/agenda', {...});
$routeProvider.when('/events/calendar', {...});
$routeProvider.when('/events/:id', {...});
The "/events/:id" route should only be matched if ":id" is a number... Currently, urls…

Gavin van Gent
- 127
- 1
- 9
5
votes
2 answers
Symfony2 using assetic with Angular HTML5 routes
I use an angular front end with Symfony. When I declare my $routeProvider I have to include my /app_dev.php/ becuase I set the html 5 mode to true: $locationProvider.html5Mode(true);.
$routeProvider.when('/app_dev.php/admin',
…

nienaber
- 189
- 2
- 12
5
votes
1 answer
possible to disable $locationProvider and $routeProvider?
Can I disable these fellas? I am using angular.js in asp.net mvc app, and I don't need angular to control anything related to address bar or the links...
Right now in html5 mode disabled ($locationProvider.html5Mode(false)) it adds hash and action…

iLemming
- 34,477
- 60
- 195
- 309
4
votes
4 answers
$routeProvider with templateURL not working
I am using $routeProvider in AngularJS with templateURl and my problem is that nothing happened, nothing shows on console and network tabs on dev tools (Chrome or Firefox). If i use template it works.
Bellow follows the hmtl and js…

Oswaldo
- 65
- 1
- 4
4
votes
2 answers
Angular routeProvider set of declared parameters?
Is it possible to only allow certain choices in the routeProvider with angularjs?
For example, if I have:
$routeProvider.when('/:action/view/', {
Can I only allow ('basketball', 'baseball') as actions for this to be set as a match?

KingKongFrog
- 13,946
- 21
- 75
- 124