flobacca
flobacca

Reputation: 978

Angular5 LandingPage without /home url

I would like my landing page URL to be myapp.com.

Currently, inside src/index.html I have

<head>
  <base href="/">
</head>

In app.component.html I have

<router-outlet></router-outlet>

In app.module.ts I have

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

I don't want to redirect myapp.com to myapp.com/home, I want myapp.com to show my landing page and I would like myapp.com/feature to show another page.

Upvotes: 0

Views: 424

Answers (2)

Pezetter
Pezetter

Reputation: 2862

If you do not want myapp.com to redirect to nyapp.com/home why are you telling it to do so?

get rid of this line:

{path: '', redirectTo: '/home', pathMatch: 'full'}

So your routes would look like this:

const appRoutes: Routes = [
  {path: '', component: HomeComponent},
  {path: 'feature', component: FeatureComponent}
];

Upvotes: 1

Ranger1230
Ranger1230

Reputation: 159

Changing your routing to have the route to your component be: {path: '', component: HomeComponent, pathMatch: 'full'} and get rid of the route performing a redirect should do just that.

Upvotes: 1

Related Questions