1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    AngularJS 1.2.x Routing Changes: ngRoute

    In AngularJS 1.2.x routing has changed. It is now required that you explicitly import ngRoute in your applications! This lesson uses an older version of AngularJS that pre-dates this change.

    Load the ngRoute library
    html<script src="angular.js">
    <script src="angular-route.js">
    Import the ngRoute module
    javascriptangular.module('app', ['ngRoute']);

    Scroll down to view the full corrected code for this lesson.

    redirectTo

    angularjsAngularJS

    In AngularJS redirectTo is often assigned a simple static string and thus points invariably to one location (redirectTo: '/mypath'). You can customize this, by setting redirectTo as a function, which arguments are the route params. For instance, if you hit the route "/pizza/peperoni", you can compose your redirection to be "/pizzas", or whatever suits your needs