step 7 & 8

This commit is contained in:
2025-11-04 10:09:57 +01:00
parent 74c1d87c43
commit a3a2798585
4 changed files with 116 additions and 20 deletions

View File

@@ -1,9 +1,12 @@
<section> <section>
<form><input type="text" placeholder="Filter by city"/> <form>
<input type="text" placeholder="Filter by city" />
<button class="primary" type="button">Search</button> <button class="primary" type="button">Search</button>
</form> </form>
</section> </section>
<section class="results"> <section class="results">
<app-housing-location [housingLocation]="housingLocation"></app-housing-location> @for(housingLocation of housingLocationList; track $index) {
<app-housing-location [housingLocation]="housingLocation"></app-housing-location>
}
</section> </section>

View File

@@ -6,20 +6,111 @@ import {HousingLocationInfo} from '../housinglocation'; // Importation de l'inte
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
imports: [HousingLocation], imports: [HousingLocation],
templateUrl: './home.html', templateUrl: 'home.html',
styleUrls: ['./home.css'], styleUrls: ['./home.css'],
}) })
export class Home { export class Home {
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common'; readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
housingLocation: HousingLocationInfo = { housingLocationList: HousingLocationInfo[] = [
id: 9999, {
name: 'Test Home', id: 0,
city: 'Test city', name: 'Acme Fresh Start Housing',
state: 'ST', city: 'Chicago',
photo: `${this.baseUrl}/example-house.jpg`, state: 'IL',
availableUnits: 99, photo: `${this.baseUrl}/bernard-hermant-CLKGGwIBTaY-unsplash.jpg`,
wifi: true, availableUnits: 4,
laundry: false, wifi: true,
}; laundry: true,
} },
{
id: 1,
name: 'A113 Transitional Housing',
city: 'Santa Monica',
state: 'CA',
photo: `${this.baseUrl}/brandon-griggs-wR11KBaB86U-unsplash.jpg`,
availableUnits: 0,
wifi: false,
laundry: true,
},
{
id: 2,
name: 'Warm Beds Housing Support',
city: 'Juneau',
state: 'AK',
photo: `${this.baseUrl}/i-do-nothing-but-love-lAyXdl1-Wmc-unsplash.jpg`,
availableUnits: 1,
wifi: false,
laundry: false,
},
{
id: 3,
name: 'Homesteady Housing',
city: 'Chicago',
state: 'IL',
photo: `${this.baseUrl}/ian-macdonald-W8z6aiwfi1E-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 4,
name: 'Happy Homes Group',
city: 'Gary',
state: 'IN',
photo: `${this.baseUrl}/krzysztof-hepner-978RAXoXnH4-unsplash.jpg`,
availableUnits: 1,
wifi: true,
laundry: false,
},
{
id: 5,
name: 'Hopeful Apartment Group',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-JvQ0Q5IkeMM-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 6,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/phil-hearing-IYfp2Ixe9nM-unsplash.jpg`,
availableUnits: 5,
wifi: true,
laundry: true,
},
{
id: 7,
name: 'Hopeful Housing Solutions',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/r-architecture-GGupkreKwxA-unsplash.jpg`,
availableUnits: 2,
wifi: true,
laundry: true,
},
{
id: 8,
name: 'Seriously Safe Towns',
city: 'Oakland',
state: 'CA',
photo: `${this.baseUrl}/saru-robert-9rP3mxf8qWI-unsplash.jpg`,
availableUnits: 10,
wifi: false,
laundry: false,
},
{
id: 9,
name: 'Capital Safe Towns',
city: 'Portland',
state: 'OR',
photo: `${this.baseUrl}/webaliser-_TPTXZd9mOo-unsplash.jpg`,
availableUnits: 6,
wifi: true,
laundry: true,
},
];
}

View File

@@ -0,0 +1,6 @@
<section class="listing">
<img class="listing-photo" [src]="housingLocation().photo"
alt="Exterior photo of {{ housingLocation().name }}" crossorigin/>
<h2 class="listing-heading">{{ housingLocation().name }}</h2>
<p class="listing-location">{{ housingLocation().city }}, {{ housingLocation().state }}</p>
</section>

View File

@@ -3,11 +3,7 @@ import {HousingLocationInfo} from '../housinglocation'; // Interface
@Component({ @Component({
selector: 'app-housing-location', selector: 'app-housing-location',
imports: [], imports: [],
template: ` templateUrl: './housing-location.html',
<p>
housing-location works!
</p>
`,
styleUrls: ['./housing-location.css'], styleUrls: ['./housing-location.css'],
}) })
export class HousingLocation { export class HousingLocation {