1

I am building a route in angular as show below:

const routes: Routes = [
  {path:'home', component: HomeComponent},
  {path:'', redirectTo: 'home', pathMatch: 'full'},
  {path:'**', redirectTo: 'home', pathMatch: 'full'}
];

But when I open the webpage like http://localhost:4200/, it redirects to http://localhost:4200/home, which is the expected behavior, but I want to hide the /home at the end. Please dont be limited to this example only, this is only a simple scenario. Is there any way to do it.
Thanks

1
  • 1
    It doesn't make sense, just route path "" to HomeComponent Commented Jan 18, 2022 at 20:41

1 Answer 1

5

yes, of course. In your code, if you navigate to a particular component, you can then use this:

this.router.navigate(['/planning/capplanning'], {
      skipLocationChange: true,
    });
Sign up to request clarification or add additional context in comments.

2 Comments

What about from the home page like lets say I just input localhost:4200 but it should go to /home but not show it. Any idea
What about from the home page itself like I go to 4200/ but it should go to home component but not show /home over there. Any idea

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.