How do you prefix a URL route with a dynamic $scope value after being called?-Collection of common programming errors

I am trying to prefix my users’ usernames to the routes they call within my application after they’ve logged in. How would I achieve this in angular? I already tried using the $locationProvider and prefixing it but it isn’t dynamic. I need to have it be dynamic accepting a value stored in the $rootScope but since the $rootScope is a service and not a provider it can’t be injected into the provider config function. How do I achieve this prefix?

kmApp.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {
    $locationProvider.html5Mode(false).hashPrefix('username');
    $routeProvider
    .when('/campaign/create/:campaignid', {
        templateUrl: 'modules/campaign/views/edit.html',
        controller: 'kmApp.modules.campaign.editAction'
    })
    .when('/campaign/view', {
        templateUrl: 'modules/campaign/views/index.html',
        controller: 'kmApp.modules.campaign.indexAction'
    })
    .when('/campaign/edit/:campaignid', {
        templateUrl: 'modules/campaign/views/edit.html',
        controller: 'kmApp.modules.campaign.editAction'
    })
    .when('/dashboard', {
        templateUrl: 'modules/dashboard/views/index.html',
        controller: 'kmApp.modules.dashboard.indexAction',
        resolve: {
            routeChange: function ($q, $rootScope, $location) {
                var defer = $q.defer();
                if ($rootScope.UserData.clientName !== undefined) {
                    $location.hash($rootScope.UserData.clientName);
                }
                defer.resolve();
                return defer.promise;
            }
        }
    })
    .when('/settings', {
        templateUrl: 'modules/config/views/index.html',
        controller: 'kmApp.modules.config.indexAction'
    })
    .when('/login', {
        controller: 'kmApp.controller.rootLayout'
    })
    .when('/addClient', {
        templateUrl: 'modules/clients/views/index.html',
        controller: 'kmApp.modules.clients.indexAction'
    })
    .when('/kmAdmin', {
        templateUrl: 'modules/clients/views/clientadmin.html',
        controller: 'kmApp.modules.clients.clientAdmin'
    })
    .when('/kmAdmin/digitalProp/:clientId', {
        templateUrl: 'modules/clients/views/digitProp.html',
        controller: 'kmApp.modules.clients.digitPropAction'
    })
    .when('/kmAdmin/distribution/:clientId', {
        templateUrl: 'modules/clients/views/distribution.html',
        controller: 'kmApp.modules.clients.distributionAction'
    })
    .when('/changePassword', {
        templateUrl: 'modules/config/views/changePassword.html',
        controller: 'kmApp.modules.config.changePassword'
    })
    .otherwise({
        redirect: ':clientName/dashboard'
    });
} ]);

Originally posted 2013-12-02 01:20:32.