Commit 7111c554 authored by ccottier's avatar ccottier

added 404 not found to routing page for invalid URLs

parent ff56f46f
import { NotFoundComponent } from './not-found/not-found.component';
import { SpainComponent } from './spain/spain.component'; import { SpainComponent } from './spain/spain.component';
import { GreeceComponent } from './greece/greece.component'; import { GreeceComponent } from './greece/greece.component';
import { AccountComponent } from './account/account.component'; import { AccountComponent } from './account/account.component';
...@@ -15,7 +16,8 @@ const routes: Routes = [ ...@@ -15,7 +16,8 @@ const routes: Routes = [
{path:'account', component: AccountComponent}, {path:'account', component: AccountComponent},
{path:'greece', component: GreeceComponent}, {path:'greece', component: GreeceComponent},
{path:'spain', component: SpainComponent}, {path:'spain', component: SpainComponent},
{path: 'contact-us', component: ContactUsComponent} {path: 'contact-us', component: ContactUsComponent},
{path: '**', component: NotFoundComponent}
]; ];
@NgModule({ @NgModule({
......
...@@ -14,6 +14,7 @@ import { AccountComponent } from './account/account.component'; ...@@ -14,6 +14,7 @@ import { AccountComponent } from './account/account.component';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {ReactiveFormsModule} from '@angular/forms'; import {ReactiveFormsModule} from '@angular/forms';
import { ContactUsComponent } from './contact-us/contact-us.component'; import { ContactUsComponent } from './contact-us/contact-us.component';
import { NotFoundComponent } from './not-found/not-found.component';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -25,7 +26,8 @@ import { ContactUsComponent } from './contact-us/contact-us.component'; ...@@ -25,7 +26,8 @@ import { ContactUsComponent } from './contact-us/contact-us.component';
GreeceComponent, GreeceComponent,
SpainComponent, SpainComponent,
AccountComponent, AccountComponent,
ContactUsComponent ContactUsComponent,
NotFoundComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
......
<p>contact-us works!</p>
<div> <div>
<div style="display:inline-block"> <div style="display:inline-block">
<form [formGroup]="userForm" (ngSubmit)="onSubmit()"> <form [formGroup]="userForm" (ngSubmit)="onSubmit()">
<div> <div>
<p>reactive</p> <p>Contact Us Form</p>
<div> <div>
<input type="text" formControlName="firstName" class="form-control input" placeholder="First name"> <input type="text" formControlName="firstName" class="form-control input" placeholder="First name">
</div> </div>
......
<p>england works!</p>
<div class='imgContainer' > <div class='imgContainer' >
<img class='img' src='/assets/images/england/england-bridge.jpg' /> <img class='img' src='/assets/images/england/england-bridge.jpg' />
......
<p>france works!</p>
<div > <div >
<div class="row" style="padding: 20px;"> <div class="row" style="padding: 20px;">
<div class="col-sm-10"> <div class="col-sm-10">
......
<p>greece works!</p>
<div class='imgContainer' > <div class='imgContainer' >
<img class='img' src='/assets/images/greece/greece-beach.jpg' /> <img class='img' src='/assets/images/greece/greece-beach.jpg' />
<img class='img' src='/assets/images/greece/greece-steps.jpg' /> <img class='img' src='/assets/images/greece/greece-steps.jpg' />
......
<h1>404 NOT FOUND</h1>
<h2>URL is invalid.</h2>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NotFoundComponent } from './not-found.component';
describe('NotFoundComponent', () => {
let component: NotFoundComponent;
let fixture: ComponentFixture<NotFoundComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ NotFoundComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(NotFoundComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-not-found',
templateUrl: './not-found.component.html',
styleUrls: ['./not-found.component.css']
})
export class NotFoundComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
<p>spain works!</p>
<div class='imgContainer' > <div class='imgContainer' >
<img class='img' src='/assets/images/spain/spain-barcelona.jpg' /> <img class='img' src='/assets/images/spain/spain-barcelona.jpg' />
<img class='img' src='/assets/images/spain/spain-cathedral.jpg' /> <img class='img' src='/assets/images/spain/spain-cathedral.jpg' />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment