step 9
This commit is contained in:
@@ -1,116 +1,21 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {Component, inject} from '@angular/core';
|
||||
import {HousingLocation} from '../housing-location/housing-location'; //Importation du component ici pour l'intégrer à la page
|
||||
|
||||
import {HousingLocationInfo} from '../housinglocation'; // Importation de l'interface
|
||||
|
||||
import {HousingService} from '../housing'; // Importation d'un service
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
imports: [HousingLocation],
|
||||
templateUrl: 'home.html',
|
||||
styleUrls: ['./home.css'],
|
||||
})
|
||||
|
||||
export class Home {
|
||||
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
|
||||
housingLocationList: HousingLocationInfo[] = [
|
||||
{
|
||||
id: 0,
|
||||
name: 'Acme Fresh Start Housing',
|
||||
city: 'Chicago',
|
||||
state: 'IL',
|
||||
photo: `${this.baseUrl}/bernard-hermant-CLKGGwIBTaY-unsplash.jpg`,
|
||||
availableUnits: 4,
|
||||
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,
|
||||
},
|
||||
];
|
||||
housingLocationList: HousingLocationInfo[] = [];
|
||||
housingService: HousingService = inject(HousingService);
|
||||
constructor() {
|
||||
this.housingLocationList = this.housingService.getAllHousingLocations();
|
||||
}
|
||||
}
|
||||
116
first-app/src/app/housing.ts
Normal file
116
first-app/src/app/housing.ts
Normal file
@@ -0,0 +1,116 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HousingLocationInfo} from './housinglocation';
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class HousingService {
|
||||
readonly baseUrl = 'https://angular.dev/assets/images/tutorials/common';
|
||||
protected housingLocationList: HousingLocationInfo[] = [
|
||||
{
|
||||
id: 0,
|
||||
name: 'Acme Fresh Start Housing',
|
||||
city: 'Chicago',
|
||||
state: 'IL',
|
||||
photo: `${this.baseUrl}/bernard-hermant-CLKGGwIBTaY-unsplash.jpg`,
|
||||
availableUnits: 4,
|
||||
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,
|
||||
},
|
||||
];
|
||||
getAllHousingLocations(): HousingLocationInfo[] {
|
||||
return this.housingLocationList;
|
||||
}
|
||||
getHousingLocationById(id: number): HousingLocationInfo | undefined {
|
||||
return this.housingLocationList.find((housingLocation) => housingLocation.id === id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user