import {Component, inject} from "@angular/core"; import {HotelComponent} from "./hotel.component"; import {Hotel} from "./hotel"; import {FormsModule} from "@angular/forms"; import {Lang} from "../idek/lang"; import {HotelService} from "../service/hotel.service"; import {Observable} from "rxjs"; import {AsyncPipe} from "@angular/common"; import {CurrencyComponent} from "../currency/currency.component"; @Component({ standalone: true, template: `
@for (hotel of (matchingHotels | async); track hotel.hotelId) {
} @empty {

no matching results for {{search}}

} `, imports: [FormsModule, HotelComponent, AsyncPipe, CurrencyComponent], providers: [HotelService], selector: 'app-hotels' }) export class HotelsComponent { public currency: Lang = {name: 'de', code: 'de-DE', currency: 'EUR'}; public search: string = ''; private hotelService: HotelService= inject(HotelService); public matchingHotels: Observable = this.hotelService.getHotels(); public searchEvent(input: string) { this.search = input.toLowerCase(); //this.matchingHotels.pipe(filter((hotel: Hotel) => hotel.hotelName.toLowerCase().includes(input.toLowerCase()))); } }