Questions tagged [angularjs-routing]

Use for ngRoute, the built-in routing module in AngularJS, which can map the browser URL to a defined route.

Is used for deep-linking URLs to controllers and views (HTML partials).
It watches $location.url() and tries to map the path to an existing route definition.

Routes can be defined through the $routeProvider API. The $route service is typically used in conjunction with ngView directive and the $routeParams service.

See:

Related tags

1283 questions
1111
votes
15 answers

What is the difference between angular-route and angular-ui-router?

I'm planning to use AngularJS in my big applications. I'm in the process to find out the right modules to use. What is the difference between ngRoute (angular-route.js) and ui-router (angular-ui-router.js) modules? In many articles when ngRoute is…
322
votes
13 answers

Delaying AngularJS route change until model loaded to prevent flicker

I am wondering if there is a way (similar to Gmail) for AngularJS to delay showing a new route until after each model and its data has been fetched using its respective services. For example, if there were a ProjectsController that listed all…
Misko Hevery
  • 47,936
  • 11
  • 40
  • 36
272
votes
18 answers

Changing route doesn't scroll to top in the new page

I've found some undesired, at least for me, behaviour when the route changes. In the step 11 of the tutorial http://angular.github.io/angular-phonecat/step-11/app/#/phones you can see the list of phones. If you scroll to the bottom and click on one…
Matias Gonzalez
  • 2,930
  • 2
  • 15
  • 8
245
votes
8 answers

How/when to use ng-click to call a route?

Suppose you are using routes: // bootstrap myApp.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { $routeProvider.when('/home', { templateUrl: 'partials/home.html', controller:…
178
votes
3 answers

What is the difference between $routeProvider and $stateProvider?

Please explain the difference between $routeProvider and $stateProvider in AngularJS. Which is best practice?
YYY
  • 3,440
  • 5
  • 20
  • 24
169
votes
4 answers

Can angularjs routes have optional parameter values?

Can I set a route with optional params (same template and controller, but some params should be ignored if they don't exist? So instead of writing the following two rules, have only one? module.config(['$routeProvider', function($routeProvider) { …
Alexandru R
  • 8,560
  • 16
  • 64
  • 98
158
votes
14 answers

Angular - ui-router get previous state

Is there a way to get the previous state of the current state? For example I would like to know what the previous state was before current state B (where previous state would have been state A). I am not able to find it in ui-router github doc…
Mihai H
  • 3,291
  • 4
  • 25
  • 34
80
votes
9 answers

Updating URL in Angular JS without re-rendering view

I'm building a dashboard system in AngularJS and I'm running into an issue with setting the url via $location.path In our dashboard, we have a bunch of widgets. Each shows a larger maximized view when you click on it. We are trying to setup deep…
Ian Muir
  • 911
  • 1
  • 9
  • 10
54
votes
1 answer

How to use ASP.NET MVC and AngularJS routing?

I’m working on a new ASP.NET MVC and AngularJS application that is intended to be a collection of SPAs. I’m using the MVC areas concept to separate each individual SPA, and then I’m using AngularJS within each MVC area to create the SPA. Since I’m…
lmttag
  • 2,499
  • 4
  • 26
  • 30
51
votes
8 answers

angularjs getting previous route path

{{header}}

{{back.text}}
In my module config …
Gihan
  • 4,163
  • 6
  • 31
  • 49
46
votes
5 answers

Is there a way to preload templates when using AngularJS routing?

After the Angular app is loaded I need some of the templates to be available offline. Something like this would be ideal: $routeProvider .when('/p1', { controller: controller1, templateUrl: 'Template1.html', preload: true })
andersh
  • 8,105
  • 6
  • 39
  • 30
46
votes
5 answers

Using grunt server, how can I redirect all requests to root url?

I am building my first Angular.js application and I'm using Yeoman. Yeoman uses Grunt to allow you to run a node.js connect server with the command 'grunt server'. I'm running my angular application in html5 mode. According to the angular docs,…
Charlie Martin
  • 8,208
  • 3
  • 35
  • 41
45
votes
5 answers

AngularJS and Handling 404 Errors

What is the best way to serve up proper 404's with an AngularJS app? A little background: I'm building an Angular app and have opted to use $locationProvider.html5Mode(true); because I want the URLs to appear natural (and indistinguishable from a…
43
votes
7 answers

How to check for the existence of a module without an error being raised?

In Angular 1.2, ngRoute is a separate module so you can use other community routers like ui.router instead. I'm writing an open-source module that aims to work for multiple different router implementations. So how can I check which router is loaded…
XåpplI'-I0llwlg'I -
  • 21,649
  • 28
  • 102
  • 151
41
votes
3 answers

angularjs route unit testing

As we see here in http://docs.angularjs.org/tutorial/step_07, angular.module('phonecat', []). config(['$routeProvider', function($routeProvider) { $routeProvider. when('/phones', {templateUrl: 'partials/phone-list.html', controller:…
allenhwkim
  • 27,270
  • 18
  • 89
  • 122
1
2 3
85 86