Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 fallback route

Tags:

How can I configure Angular2 router to redirect me to a default route (or any other) if I go to a non existent route?

like image 851
Vlado Tesanovic Avatar asked Jan 04 '16 16:01

Vlado Tesanovic


People also ask

What is fallback route?

Now that you are familiar with the purpose of a Router, you will now learn about the Fallback Route which is a route a bundle passes through only when it cannot pass through any other route within a scenario hence the name fallback.

Can we have two router outlet?

You can have multiple router-outlet in same template by configuring your router and providing name to your router-outlet, you can achieve this as follows. Advantage of below approach is thats you can avoid dirty looking URL with it.

What is auxiliary routes?

Auxiliary Routes are independent, secondary routes that can be added to a page along with a primary route. As an example, we can have a side-menu that lives within the primary route with its own router-outlet : that's an auxiliary route.


1 Answers

I found this solution

{ component: HomeComponent, path: "", pathMatch: "full" }, { component: LoginComponent, path: "/login" }, { component: NotFoundComponent, path: "**" } 
like image 99
Vlado Tesanovic Avatar answered Oct 08 '22 23:10

Vlado Tesanovic