Question

I am just getting started with an angular project. We have a number of simple views and controllers, and have been using the mechanism provided by $routeProvider to map controllers to views. Upon updating to angular v1.2.0 the $routeProvider mechanism appears to be gone and replaced with something better. However, I have not been able to find a coherent code example showing how to make the switch.

What I have looks like this:

theApp.config(function ($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl: 'views/main.html',
            controller: 'MainCtrl'
        })
        .when('/foo', {
            templateUrl: 'views/foo.html',
            controller: 'FooCtrl'
        })...

What has that changed to?

Thanks

Was it helpful?

Solution

It is still $routeProvider, but they moved it out into a module. You need to add it to the list of dependencies for your app by injecting 'ngRoute'.

You can get the routing module with the others for http://code.angularjs.org/1.2.0-rc.2/ here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top