Redirect to a new page in Angular 2 Routing

Viewed 44731

I have a scenario say a Home Page(app.component.ts with main.html) which is routed as default

app.component.ts

@RouteConfig([
    {path: '/',name : 'Home' , component : HomeComponent , useAsDefault: true },
    {path: '/user', name : 'User' , component : UserComponent },
    {path: '/about', name : 'About' , component : AboutComponent},
    {path : 'contact', name : 'Contact' , component : ContactComponent}
])

main.html

<a [routerLink]="['/Home']">Home</a>
<a [routerLink]="['/User']">User Login</a>
<a [routerLink]="['/About']">About</a>
<a [routerLink]="['/Contact']">Contact</a>

<router-outlet></router-outlet>

Now lets say for the 2 components i want to route using the router outlet, but for the User, i want to route to a entire new page i.e not in the router outlet . I tried navigate and navigateByUrl doesnt work it still loads it in the <router-outlet> . Please dont suggest window.href

Ive tried using the Redirect class in angular2/router , but unable to do the needful.

3 Answers
Related