Skip to content

Commit

Permalink
added page not found wildcard route
Browse files Browse the repository at this point in the history
  • Loading branch information
rmroot committed Feb 1, 2024
1 parent 3f311b7 commit c50aacd
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -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 = [
{
Expand All @@ -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 },

];

Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="row justify-content-center pt-3">
<div class="card col-lg-6 col-sm-10">
<div class="card-body">
<div class="card-title display-4">
404 Page Not Found
</div>
<p class="card-text">
We weren't able to find the page you were looking for. Please return to the dashboard by clicking the
button below.
</p>
<hr>
<button class="btn btn-primary" routerLink="/">Back to Dashboard</button>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -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<PageNotFoundComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [PageNotFoundComponent]
});
fixture = TestBed.createComponent(PageNotFoundComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions src/app/core-components/page-not-found/page-not-found.component.ts
Original file line number Diff line number Diff line change
@@ -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 {

}

0 comments on commit c50aacd

Please sign in to comment.