ey dee ey em
ey dee ey em

Reputation: 8593

How to config rootScope to set up routing address

When loading a routing address into the routeProvider in .config stage, I want to simultaneously setup the route addresses under $rootScope, so that all the other services can access the routing correctly.

For example, like this:

$rootScope.jsModules='js/modules/';
    $rootScope.appModule={
        addressbookHomeModule: {
            mName:'homeController',
            route: 'addressbook-home/',
            template: route+'home.html',
            controller: route+'homeController.js',

        },

However, I found and researched that its not possible to config $rootScope at the point of .config.

If it's possible to config $rootScope just by attaching another object onto it, how can I do that?

If not, I wonder if there a better way and more efficient way to store the routing location string like partials/confirmed.html so that all the other services can access the route correctly when I only need to config the string of the routing location once instead of all around the files in all the services?

Upvotes: 1

Views: 340

Answers (1)

Rahul Ravindran
Rahul Ravindran

Reputation: 318

We can use angular.constant. We can inject constants into pretty much anything (factory service provider etc) once it's created. For example:

Angular.module('app).constant('routes',{home:'/'})

Upvotes: 2

Related Questions