Answers for "empty path redirection on home page in angular routing"

0

empty path redirection on home page in angular routing

/* Redirection of empty path on home page path in angular */

Now that we have added routing to the home and about components, let's see how to redirect users to the /home path when they first visit our app from the empty path.

We simply need to add a new route that matches the empty path and redirect it to the /home path as follows:

const routes: Routes = [
  { path: '', pathMatch: ‘full’, redirectTo: 'home' },
  { path: 'home', component: HomeComponent },
  { path: 'about', component: AboutComponent }

];
Internally, the router uses a function called 'applyRedirects' to process redirects.

/*
I hope it will help you.
Namaste
Stay Home Stay Safe
*/
Posted by: Guest on May-29-2020

Code answers related to "empty path redirection on home page in angular routing"

Code answers related to "Javascript"

Browse Popular Code Answers by Language