404 upon request for service. How to change the response status

I am new to Angular2. I could not find the answer to my question: how to replace the content of the answer if the service in my module fails. The scenario is that the module uses the hashed identifier from the URL to fulfill the service request. If the URL was copied incorrectly, the request fails. We thought that at this stage we should display page 404. Currently, when an error is detected, I am redirected to page 404. It seems to me that this behavior causes problems similar to those in the browser that the back operation is problematic.

Any idea?

+4
source share
1 answer

,

:

{
    // all unvalid urls, get redirected to page not found page
    path: '**',
    component: PageNotFoundComponent,
}

URL-, , , :

this._router.navigateByUrl('/pagenotfound', { skipLocationChange: true }) 

skipLocationChange, , "" , "" 404, .

+1

Source: https://habr.com/ru/post/1666417/


All Articles