From the course: Angular: Animations

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Create a 404 route view

Solution: Create a 404 route view - Angular Tutorial

From the course: Angular: Animations

Start my 1-month free trial

Solution: Create a 404 route view

(upbeat music) - [Instructor] One way to create a 404 error route view is of course to simply use Angular's routing mechanism, so here's the way I went about doing this. Inside of my routes folder, I created a new file called notfound.components.ts. Within here, I simply gave it a header in my template for 404 error page not found and then, a little message inside of the body of the view, which says the page does not exist. We export NotFoundComponent and if we go to app.module.ts, we also import NotFoundComponent from routes/notfound.component, just like we do any of the other route views that we're using. Far to the bottom of our route stack, we look to see double wildcard path and the component we serve up is of course NotFoundComponent. We'll have a look now at how this works within our project. Here, we have our project and we have our basic routes here. However, if I mistype something, there we go, 404 page not…

Contents