From a3a98be940316b38e7c5c87319cfae0e4fecb261 Mon Sep 17 00:00:00 2001 From: Phan Huy Tran Date: Wed, 13 Nov 2024 10:17:58 +0100 Subject: [PATCH] Details --- src/app/app.component.html | 8 +++- src/app/app.component.ts | 4 +- src/app/app.routes.ts | 16 ++++++- src/app/details/details.component.html | 42 ++++++++++++++++++- src/app/details/details.component.ts | 12 +++++- .../housing-location.component.html | 1 + .../housing-location.component.ts | 5 ++- 7 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index abed03f..eb71091 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,5 +1,9 @@
-

Homes

+ - +
diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 2cec76f..0f018c5 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core'; -import { RouterOutlet } from '@angular/router'; +import {RouterLink, RouterOutlet} from '@angular/router'; import {HomeComponent} from './home/home.component'; @Component({ selector: 'app-root', standalone: true, - imports: [RouterOutlet, HomeComponent], + imports: [RouterOutlet, HomeComponent, RouterLink], templateUrl: './app.component.html', styleUrl: './app.component.css' }) diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index dc39edb..e020217 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -1,3 +1,17 @@ import { Routes } from '@angular/router'; +import {HomeComponent} from './home/home.component'; +import {DetailsComponent} from './details/details.component'; -export const routes: Routes = []; +export const routes: Routes = [ + { + path: '', + component: HomeComponent, + title: 'Home page', + }, + + { + path: 'details/:id', + component: DetailsComponent, + title: 'Home Details', + }, +]; diff --git a/src/app/details/details.component.html b/src/app/details/details.component.html index 29525a6..c1c4c4c 100644 --- a/src/app/details/details.component.html +++ b/src/app/details/details.component.html @@ -1 +1,41 @@ -

details works!

+
+
+
+ Exterior photo of {{ housingLocation?.name }} +
+
+
+

{{ housingLocation?.name }}

+

{{ housingLocation?.city }}, {{ housingLocation?.state }}

+
+ +
+

About this housing location

+
    +
  • + + Units available: {{ housingLocation?.availableUnits }} +
  • +
  • + + WiFi: + {{ housingLocation?.wifi ? 'Yes' : 'No' }} + +
  • +
  • + + Laundry: + {{ housingLocation?.laundry ? 'Yes' : 'No' }} + +
  • +
+
+
+
+
diff --git a/src/app/details/details.component.ts b/src/app/details/details.component.ts index d818ab2..4961512 100644 --- a/src/app/details/details.component.ts +++ b/src/app/details/details.component.ts @@ -1,4 +1,7 @@ -import { Component } from '@angular/core'; +import {Component, inject} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {HousingService} from '../housing.service'; +import {HousingLocation} from '../housing-location'; @Component({ selector: 'app-details', @@ -8,5 +11,12 @@ import { Component } from '@angular/core'; styleUrl: './details.component.css' }) export class DetailsComponent { + route: ActivatedRoute = inject(ActivatedRoute); + housingService = inject(HousingService); + housingLocation: HousingLocation | undefined; + constructor() { + const housingLocationId = Number(this.route.snapshot.params['id']); + this.housingLocation = this.housingService.getHousingLocationById(housingLocationId); + } } diff --git a/src/app/housing-location/housing-location.component.html b/src/app/housing-location/housing-location.component.html index 49d26ae..21433bf 100644 --- a/src/app/housing-location/housing-location.component.html +++ b/src/app/housing-location/housing-location.component.html @@ -11,5 +11,6 @@

{{ housingLocation.name }}

{{ housingLocation.city }}, {{ housingLocation.state }}

+ Learn More
diff --git a/src/app/housing-location/housing-location.component.ts b/src/app/housing-location/housing-location.component.ts index 9c62703..89ab0d4 100644 --- a/src/app/housing-location/housing-location.component.ts +++ b/src/app/housing-location/housing-location.component.ts @@ -1,10 +1,13 @@ import {Component, Input} from '@angular/core'; import {HousingLocation} from '../housing-location'; +import {RouterLink} from '@angular/router'; @Component({ selector: 'app-housing-location', standalone: true, - imports: [], + imports: [ + RouterLink + ], templateUrl: './housing-location.component.html', styleUrl: './housing-location.component.css' })