2024-09-10 07:35:29 +02:00
|
|
|
import { Component, input } from '@angular/core';
|
|
|
|
import { HotelItem } from './HotelItem/HotelItem.component';
|
|
|
|
import { SearchComponent } from './Search/search.component';
|
2024-09-17 07:47:38 +02:00
|
|
|
import { UpperCasePipe } from '@angular/common';
|
|
|
|
import { TextPipe } from '../text.pipe';
|
2024-10-01 07:45:24 +02:00
|
|
|
import { HotelService } from './Parent/services/hotel.service';
|
|
|
|
import { inject } from '@angular/core';
|
2024-08-13 13:11:57 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
standalone: true,
|
2024-09-17 07:47:38 +02:00
|
|
|
imports: [HotelItem, SearchComponent, UpperCasePipe, TextPipe],
|
2024-08-13 13:11:57 +02:00
|
|
|
templateUrl: './app.component.html',
|
2024-10-01 07:45:24 +02:00
|
|
|
providers: [HotelService],
|
2024-08-13 13:11:57 +02:00
|
|
|
styleUrl: './app.component.css'
|
|
|
|
})
|
|
|
|
export class AppComponent {
|
2024-09-10 07:35:29 +02:00
|
|
|
public search: string = "";
|
2024-10-01 07:45:24 +02:00
|
|
|
public hotelService: HotelService = inject(HotelService);
|
2024-08-20 14:26:19 +02:00
|
|
|
|
2024-09-10 07:35:29 +02:00
|
|
|
public test() {
|
|
|
|
console.log(this.search);
|
2024-08-20 14:26:19 +02:00
|
|
|
}
|
2024-09-10 07:35:29 +02:00
|
|
|
|
2024-09-17 07:47:38 +02:00
|
|
|
public has_hotels(): boolean {
|
|
|
|
for (let hotel of this.hotels) {
|
|
|
|
if (hotel.hotelName.includes(this.search)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-10-01 07:45:24 +02:00
|
|
|
public hotels = this.hotelService.getHotels();
|
2024-08-13 13:11:57 +02:00
|
|
|
}
|
2024-08-20 14:26:19 +02:00
|
|
|
|