From 763d01d5610eb4d832ff296992552cec71e9e5c6 Mon Sep 17 00:00:00 2001 From: csimonis Date: Tue, 10 Sep 2024 08:41:01 +0200 Subject: [PATCH] now undo --- src/app/app.component.ts | 6 ++--- .../child-1/child-1.component.html | 0 .../{ => child}/child-1/child-1.component.ts | 0 .../child-2/child-2.component.html | 0 .../{ => child}/child-2/child-2.component.ts | 0 .../{ => child}/parent/parent.component.html | 0 .../{ => child}/parent/parent.component.ts | 0 src/app/hotel/hotels.component.ts | 27 +++++++++++++------ 8 files changed, 22 insertions(+), 11 deletions(-) rename src/app/{ => child}/child-1/child-1.component.html (100%) rename src/app/{ => child}/child-1/child-1.component.ts (100%) rename src/app/{ => child}/child-2/child-2.component.html (100%) rename src/app/{ => child}/child-2/child-2.component.ts (100%) rename src/app/{ => child}/parent/parent.component.html (100%) rename src/app/{ => child}/parent/parent.component.ts (100%) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 34e04e2..a38113b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; -import {Child1Component} from "./child-1/child-1.component"; -import {Child2Component} from "./child-2/child-2.component"; -import {ParentComponent} from "./parent/parent.component"; +import {Child1Component} from "./child/child-1/child-1.component"; +import {Child2Component} from "./child/child-2/child-2.component"; +import {ParentComponent} from "./child/parent/parent.component"; import {HotelsComponent} from "./hotel/hotels.component"; @Component({ diff --git a/src/app/child-1/child-1.component.html b/src/app/child/child-1/child-1.component.html similarity index 100% rename from src/app/child-1/child-1.component.html rename to src/app/child/child-1/child-1.component.html diff --git a/src/app/child-1/child-1.component.ts b/src/app/child/child-1/child-1.component.ts similarity index 100% rename from src/app/child-1/child-1.component.ts rename to src/app/child/child-1/child-1.component.ts diff --git a/src/app/child-2/child-2.component.html b/src/app/child/child-2/child-2.component.html similarity index 100% rename from src/app/child-2/child-2.component.html rename to src/app/child/child-2/child-2.component.html diff --git a/src/app/child-2/child-2.component.ts b/src/app/child/child-2/child-2.component.ts similarity index 100% rename from src/app/child-2/child-2.component.ts rename to src/app/child/child-2/child-2.component.ts diff --git a/src/app/parent/parent.component.html b/src/app/child/parent/parent.component.html similarity index 100% rename from src/app/parent/parent.component.html rename to src/app/child/parent/parent.component.html diff --git a/src/app/parent/parent.component.ts b/src/app/child/parent/parent.component.ts similarity index 100% rename from src/app/parent/parent.component.ts rename to src/app/child/parent/parent.component.ts diff --git a/src/app/hotel/hotels.component.ts b/src/app/hotel/hotels.component.ts index d0ddfd4..8bf634c 100644 --- a/src/app/hotel/hotels.component.ts +++ b/src/app/hotel/hotels.component.ts @@ -1,5 +1,4 @@ import {Component} from "@angular/core"; -import {NgFor, NgIf} from "@angular/common"; import {HotelComponent} from "./hotel.component"; import {Hotel} from "./hotel"; import {FormsModule} from "@angular/forms"; @@ -10,24 +9,36 @@ import {FormsModule} from "@angular/forms";
- -
+ @for (hotel of matchingHotels; track hotel.hotelId) {
-
-
+ } @empty { +

no matching results for {{search}}

+ } `, - imports: [NgFor, NgIf, FormsModule, HotelComponent], + imports: [FormsModule, HotelComponent], selector: 'app-hotels' }) export class HotelsComponent { - public search: string = '' + public search: string = ''; + + public matchingHotels: Hotel[] = []; + + constructor() { + this.matchingHotels = this.hotels; + } public searchEvent(input: string) { this.search = input.toLowerCase(); + this.matchingHotels = [] + this.hotels.forEach((hotel: Hotel) => { + if (hotel.hotelName.toLowerCase().includes(this.search)) { + this.matchingHotels.push(hotel); + } + }) } - hotels: Hotel[] = [ + public hotels: Hotel[] = [ { "hotelId": 1, "hotelName": "Buea süßes Leben",