This commit is contained in:
Constantin Simonis 2025-01-28 09:13:20 +01:00
parent 9a45f5099a
commit 0a147afca0
Signed by: csimonis
GPG Key ID: 758DD9C506603183

View File

@ -4,8 +4,8 @@ import {Hotel} from "../model/hotel";
import {FormsModule} from "@angular/forms"; import {FormsModule} from "@angular/forms";
import {Lang} from "../../currency/lang"; import {Lang} from "../../currency/lang";
import {HotelService} from "../service/hotel.service"; import {HotelService} from "../service/hotel.service";
import {filter, Observable, toArray} from "rxjs"; import {Observable} from "rxjs";
import {AsyncPipe} from "@angular/common"; import {AsyncPipe, NgIf} from "@angular/common";
import {CurrencyComponent} from "../../currency/currency.component"; import {CurrencyComponent} from "../../currency/currency.component";
import {RouterLink} from "@angular/router"; import {RouterLink} from "@angular/router";
import {StarComponent} from "./star.component"; import {StarComponent} from "./star.component";
@ -19,16 +19,18 @@ import {StarComponent} from "./star.component";
</form> </form>
<p routerLink="/hotels/new">Create Hotel</p> <p routerLink="/hotels/new">Create Hotel</p>
@for (hotel of (matchingHotels | async); track hotel.id) { @for (hotel of (matchingHotels | async); track hotel.id) {
<div>{{hotel.hotelName}}</div> <div *ngIf="hotel.hotelName.toLowerCase().includes(search)">
<div>{{ hotel.hotelName }}</div>
<img src="{{hotel.imageUrl}}" alt="{{hotel.hotelName}}" height="64" width="64"> <img src="{{hotel.imageUrl}}" alt="{{hotel.hotelName}}" height="64" width="64">
<br> <br>
<button routerLink="{{hotel.id}}">Details</button> <button routerLink="{{hotel.id}}">Details</button>
<hr> <hr>
</div>
} @empty { } @empty {
<h1>no matching results for {{ search }}</h1> <h1>no matching results for {{ search }}</h1>
} }
`, `,
imports: [FormsModule, HotelComponent, AsyncPipe, CurrencyComponent, RouterLink, StarComponent], imports: [FormsModule, HotelComponent, AsyncPipe, CurrencyComponent, RouterLink, StarComponent, NgIf],
providers: [HotelService], providers: [HotelService],
selector: 'app-hotels' selector: 'app-hotels'
}) })