angular-hotel-manager/src/app/app.component.ts

37 lines
998 B
TypeScript
Raw Normal View History

import { Component, input } from '@angular/core';
import { HotelItem } from './HotelItem/HotelItem.component';
import { SearchComponent } from './Search/search.component';
import { UpperCasePipe } from '@angular/common';
import { TextPipe } from '../text.pipe';
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,
imports: [HotelItem, SearchComponent, UpperCasePipe, TextPipe],
2024-08-13 13:11:57 +02:00
templateUrl: './app.component.html',
providers: [HotelService],
2024-08-13 13:11:57 +02:00
styleUrl: './app.component.css'
})
export class AppComponent {
public search: string = "";
public hotelService: HotelService = inject(HotelService);
2024-08-20 14:26:19 +02:00
public test() {
console.log(this.search);
2024-08-20 14:26:19 +02:00
}
public has_hotels(): boolean {
for (let hotel of this.hotels) {
if (hotel.hotelName.includes(this.search)) {
return true;
}
}
return false;
}
public hotels = this.hotelService.getHotels();
2024-08-13 13:11:57 +02:00
}
2024-08-20 14:26:19 +02:00