Loading…

How to redirect to 404 or other path if the path does not exist in Angular 2?

Using angular routing you can navigate from one view or page to another while performing your tasks. You can configure a URL to redirect to the next URL. This feature can be handled to address the "404 Not Found" problem. Using location services in Angular routing you can go back and forward through the history of pages.

Syntax : We can use {path: '/OUR_PATH', redirectTo: ['redirectPathName']}

Go through this Angular 2 interview questions very thoroughly

Example

                                        

{path: '/404', name: 'PageNotFound', component: NotFoundComponent}

Suggest An Answer

No suggestions avaliable!

Latest post from Angular 2 Interview Questions

Ask Question