How to redirect to home route when no route is defined?

In AngularJs, $routeProvider is used for configuring routes.

Requires the ngRoute module to be installed.

when(path, route);

Adds a new route definition to the $route service.

$routeProvider.when(‘/index’, { templateUrl: ‘/view/project.html’, controller: ‘projectController’ });

You can use,

otherwise(params)

Sets route definition that will be used on route change when no other route definition is matched.

.otherwise({ redirectTo: ‘/Home’ });

To redirect to home page when no other route is provided.


ProsperaSoft offers AngularJs development solutions. You can email at info@prosperasoft.com to get in touch with ProsperaSoft AngularJs experts and consultants.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>