Reputation: 75
I used Angular.js routing mechanism where I want to set my home route as default, so that when I open application will use that default routing.
Example When I open application as follows url is www.abc.com
Code :
var portalModule = angular.module("portalModule", ['ngRoute']).config(function ($routeProvider, $locationProvider) {
//Path - it should be same as href link
$routeProvider.when('/Home', { templateUrl: '/PortalTemplate/Home.html', controller: 'homeController' });
//List routing
$routeProvider.when('/ProductList', { templateUrl: '/PortalTemplate/ProductList.html', controller: 'productController' });
$routeProvider.when('/ShopList', { templateUrl: '/PortalTemplate/ShopList.html', controller: 'shopController' });
$routeProvider.when('/ServiceList', { templateUrl: '/PortalTemplate/ServiceList.html', controller: 'serviceController' });
//Detail Routing
$routeProvider.when('/ProductDetail', { templateUrl: '/PortalTemplate/ProductDetail.html', controller: 'productDetailController' });
$routeProvider.when('/ShopDetail', { templateUrl: '/PortalTemplate/ShopDetail.html', controller: 'shopDetailController' });
$routeProvider.when('/ServiceDetail', { templateUrl: '/PortalTemplate/ServiceDetail.html', controller: 'serviceDetailController' });
$locationProvider.html5Mode(true);
});
So I want /Home route will open as whenever I open my application as www.abc.com/Home by default.
Upvotes: 0
Views: 63
Reputation: 18769
You can use .otherwise(params);
which will catch anything else that doesn't match. See roteProvider docs here.
$routeProvider.when(...)
$routeProvider.when(...)
.otherwise({ redirectTo: '/Home' });
Upvotes: 1