You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,3 +327,80 @@ nav a.active {
327
327
background-color: #CFD8DC;
328
328
}
329
329
```
330
+
331
+
2 Wildcard Route and Redirecting Routes (Dealing with unavailable-non-configured route [Page not found])
332
+
=====================
333
+
- User can type/enter any unavailable-non-configured route/URL and can get many erros in console, like `http://localhost:5000/try`**Error:**`(Cannot match any routes, URL segment 'try'...)`
334
+
- To deal/handle any unwanted path or unavailable routes we must need to create a new component named `page not found component` OR `404 component` and `add 'wildcard **'` route
335
+
-`Wildcard **` routes or any paths with parameters (employees/1 or routes/parameters) `must come last` in `app-routing.module.ts` router configuration as router tries to match the paths from top to bottom
336
+
- In `app-routing.module.ts` route must be configured in order: `most specific at the tpo to list important/specific at the bottom`
337
+
-**Default Route:** While using `wildcard **` routes we also need to provide `default route like '{ path: '', component:DepartmentListComponent}' OR '{ path: '', redirectTo:'departments', pathMatch:'full'}'`
338
+
<br/> <br/>
339
+
340
+
Steps:
341
+
- Create a new component for page not found: `ng g c wildcard-pagenotfound` with a instructional markup: `404 page not found!`
342
+
- In `app-routing.module.ts` at the bottom/last add a new wildcard route: `{ path: '**', component: WildcardPagenotfoundComponent }`
0 commit comments