Kalas Yagami Kalas Yagami - 1 year ago 137
Javascript Question

Which router for Angular1.5?

This question seems a bit "IdidntwanttosearchonGoogle" but I did. A lot, and anything worked.

I'm trying to build a little web app with angular 1.5. The problem is that I never used route (NEVER !), and Angular 1.5 seems ambiguous about it. I've seen that 1.5 uses Component Router like Angular 2, then on the Angular page it says that it is deprecated and we have to use ngRoute.

The fact is that anyway, I don't manage to understand which to take and how to use it. Tried this in my bower.json :

"name": "doit"
"dependencies": {
"angular": "1.5.8",
"angular-component-router": "0.2.0"

And in my index.html :

<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" integrity="sha384-MIwDKRSSImVFAZCVLtU0LMDdON6KVCrZHyVQQj6e8wIEJkW4tvwqXrbMIya1vriY" crossorigin="anonymous">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>DoIt Application</title>
<script src="bower_components/angular/angular.js"></script>
<script src="bootstrap.js"></script>
<script src="app/app.component.js"></script>
<script src="bower_components/angular-component-router/angular_1_router.js"></script>
<script src="bower_components/angular-component-router/ng_route_shim.js"></script>

<body ng-app="app">


If you have a guide that explain routes in Angular 1.5 correctly, who works, It would be perfect !

iQ. iQ.
Answer Source

Are you specifically wanting to use the Angular 1.5 router or are you asking for suggestions on which router library to use?

Personally if you are not strict on using the Angular router, I would recommend using ui-router, it has become almost a standard in angular apps anyway.

Things I like about it:

  1. It is well maintained and very stable.
  2. Easy to configure and comprehensive.
  3. Simple directives that easily allow navigation on tags.
  4. Good parent child support (e.g. /Categories, /Categories/Football)
  5. Large community support so you will find lots of guides and help easily.


Put this in your bower.json:

  "angular-ui-router": "~0.3.1"

Put this in your app:

angular.module('myApp', ['ui.router', ...other dependencies]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download