routeProvider not working correctly

user2786754 picture user2786754 · Jan 8, 2014 · Viewed 9.8k times · Source

Im using angularJS to set where i want the page to go after i login, but if i only have this

function routeProviderFunction($routeProvider){
$routeProvider.when('/default',{
    templateUrl: 'HTML/login.html',
    controller: funct2
});

$routeProvider.otherwise({
    redirectTo: '/default'
});
}

My route provider works in the above code, but after i turn it into this

    function routeProviderFunction($routeProvider){
$routeProvider.when('/default',{
    templateUrl: 'HTML/login.html',
    controller: funct2
});
$routeProvider.when('/adminMenu/:username', {
     templateUrl: 'HTML/adminMenu.html',
     controller: adminMenu
     });


$routeProvider.otherwise({
    redirectTo: '/default'
});
}

My route provider ceases to work at all. Any ideas

Answer

fabuloso picture fabuloso · Jan 8, 2014

try to do like this:

$routeProvider
            .when('/default', {
                templateUrl: 'HTML/login.html',
                controller : 'funct2'
            }).when('/adminMenu/:username', {
                templateUrl: 'HTML/adminMenu.html',
                controller : 'adminMenu'
            }).otherwise({
                redirectTo : '/default'
            });