From c50aacd40fafe0eb6d4896800d532f8ad0516483 Mon Sep 17 00:00:00 2001 From: rmroot Date: Thu, 1 Feb 2024 14:15:45 -0600 Subject: [PATCH] added page not found wildcard route --- src/app/app-routing.module.ts | 6 +++++- src/app/app.module.ts | 4 +++- .../page-not-found.component.css | 0 .../page-not-found.component.html | 15 +++++++++++++ .../page-not-found.component.spec.ts | 21 +++++++++++++++++++ .../page-not-found.component.ts | 10 +++++++++ 6 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/app/core-components/page-not-found/page-not-found.component.css create mode 100644 src/app/core-components/page-not-found/page-not-found.component.html create mode 100644 src/app/core-components/page-not-found/page-not-found.component.spec.ts create mode 100644 src/app/core-components/page-not-found/page-not-found.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1800debb..63a81bb2 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -1,6 +1,7 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { WelcomeComponent } from './core-components/welcome/welcome.component'; +import { PageNotFoundComponent } from './core-components/page-not-found/page-not-found.component'; const routes: Routes = [ { @@ -11,7 +12,10 @@ const routes: Routes = [ { path: 'welcome', component: WelcomeComponent - } + }, + //wildcard/page not found needs to be last route + //triggered after entire route tree is checked + { path: "**", component: PageNotFoundComponent }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 8d0bea9d..7f08bffc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -5,12 +5,14 @@ import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { NavbarComponent } from './core-components/navbar/navbar.component'; import { WelcomeComponent } from './core-components/welcome/welcome.component'; +import { PageNotFoundComponent } from './core-components/page-not-found/page-not-found.component'; @NgModule({ declarations: [ AppComponent, NavbarComponent, - WelcomeComponent + WelcomeComponent, + PageNotFoundComponent ], imports: [ BrowserModule, diff --git a/src/app/core-components/page-not-found/page-not-found.component.css b/src/app/core-components/page-not-found/page-not-found.component.css new file mode 100644 index 00000000..e69de29b diff --git a/src/app/core-components/page-not-found/page-not-found.component.html b/src/app/core-components/page-not-found/page-not-found.component.html new file mode 100644 index 00000000..8d8e23bc --- /dev/null +++ b/src/app/core-components/page-not-found/page-not-found.component.html @@ -0,0 +1,15 @@ +
+
+
+
+ 404 Page Not Found +
+

+ We weren't able to find the page you were looking for. Please return to the dashboard by clicking the + button below. +

+
+ +
+
+
\ No newline at end of file diff --git a/src/app/core-components/page-not-found/page-not-found.component.spec.ts b/src/app/core-components/page-not-found/page-not-found.component.spec.ts new file mode 100644 index 00000000..4171646f --- /dev/null +++ b/src/app/core-components/page-not-found/page-not-found.component.spec.ts @@ -0,0 +1,21 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageNotFoundComponent } from './page-not-found.component'; + +describe('PageNotFoundComponent', () => { + let component: PageNotFoundComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [PageNotFoundComponent] + }); + fixture = TestBed.createComponent(PageNotFoundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/core-components/page-not-found/page-not-found.component.ts b/src/app/core-components/page-not-found/page-not-found.component.ts new file mode 100644 index 00000000..3f5686d0 --- /dev/null +++ b/src/app/core-components/page-not-found/page-not-found.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-page-not-found', + templateUrl: './page-not-found.component.html', + styleUrls: ['./page-not-found.component.css'] +}) +export class PageNotFoundComponent { + +}