T
T
tehnazavr2019-01-14 17:04:37
Angular
tehnazavr, 2019-01-14 17:04:37

How to make a 404 page in angular 2?

Hello everybody. In spa on angular, you need to make sure that your component is displayed for 404 errors. Partly I found how to do it in the documentation. In the router, in the path property, I write '**' last after all other paths. However, the method does not work quite as it should. Works only for paths with two or more slashes.
Those. i want https://example.com/lorem to be 404. It only works if https://example.com/lorem/xxx

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
msdosx86, 2019-01-14
@msdosx86

Maybe you don't write well. If for root routing add

{
  path: '**',
  component: NotFoundComponent,
}

That will work. Another thing is if you have nested routes and you need to add such a route to them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question