still dont know
This commit is contained in:
parent
073893b677
commit
00c112a119
BIN
public/assets/img/heisenberg.jpg
Normal file
BIN
public/assets/img/heisenberg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.5 KiB |
BIN
public/assets/img/huy.png
Normal file
BIN
public/assets/img/huy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 169 KiB |
BIN
public/assets/img/kjan.png
Normal file
BIN
public/assets/img/kjan.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
BIN
public/assets/img/rat.png
Normal file
BIN
public/assets/img/rat.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 177 KiB |
@ -1 +0,0 @@
|
||||
<app-parent></app-parent>
|
@ -2,14 +2,15 @@ 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 {HotelsComponent} from "./hotel/hotels.component";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.css',
|
||||
imports: [Child1Component, Child2Component, ParentComponent],
|
||||
imports: [Child1Component, Child2Component, ParentComponent, HotelsComponent],
|
||||
template: `
|
||||
<app-hotels></app-hotels>
|
||||
`
|
||||
})
|
||||
export class AppComponent {
|
||||
public title: string = 'hotel-manager';
|
||||
}
|
||||
|
21
src/app/hotel/hotel.component.ts
Normal file
21
src/app/hotel/hotel.component.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import {Component, Input} from "@angular/core";
|
||||
import {Hotel} from "./hotel"
|
||||
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: 'app-hotel',
|
||||
template: `
|
||||
<div style="border: white 2px; border-radius: 2px">
|
||||
<p class="name">Name: {{hotel.hotelName}}</p>
|
||||
<p>Beschreibung: {{hotel.description}}</p>
|
||||
<p>Preis: {{hotel.price}}/nacht</p>
|
||||
<p>Sterne: {{hotel.rating}}/5</p>
|
||||
<img width="64" height="64" src="{{hotel.imageUrl}}">
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class HotelComponent {
|
||||
@Input()
|
||||
public hotel!: Hotel;
|
||||
}
|
8
src/app/hotel/hotel.ts
Normal file
8
src/app/hotel/hotel.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export interface Hotel {
|
||||
hotelId: number;
|
||||
hotelName: string;
|
||||
description: string;
|
||||
price: number;
|
||||
imageUrl: string;
|
||||
rating: number;
|
||||
}
|
64
src/app/hotel/hotels.component.ts
Normal file
64
src/app/hotel/hotels.component.ts
Normal file
@ -0,0 +1,64 @@
|
||||
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";
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
template: `
|
||||
<form>
|
||||
<input name="search" [ngModel]="search" (ngModelChange)="searchEvent($event)">
|
||||
</form>
|
||||
<ng-container *ngFor="let hotel of hotels">
|
||||
<div *ngIf="search === '' || hotel.hotelName.toLowerCase().includes(search)">
|
||||
<app-hotel [hotel]="hotel"></app-hotel>
|
||||
<hr>
|
||||
</div>
|
||||
</ng-container>
|
||||
`,
|
||||
imports: [NgFor, NgIf, FormsModule, HotelComponent],
|
||||
selector: 'app-hotels'
|
||||
})
|
||||
export class HotelsComponent {
|
||||
public search: string = ''
|
||||
|
||||
public searchEvent(input: string) {
|
||||
this.search = input.toLowerCase();
|
||||
}
|
||||
|
||||
hotels: Hotel[] = [
|
||||
{
|
||||
"hotelId": 1,
|
||||
"hotelName": "Buea süßes Leben",
|
||||
"description": "Schöne Aussicht am Meer",
|
||||
"price": 230.5,
|
||||
"imageUrl": "assets/img/heisenberg.jpg",
|
||||
"rating": 3.5
|
||||
},
|
||||
{
|
||||
"hotelId": 2,
|
||||
"hotelName": "Marrakesch",
|
||||
"description": "Genießen Sie den Blick auf die Berge",
|
||||
"price": 145.5,
|
||||
"imageUrl": "assets/img/kjan.png",
|
||||
"rating": 5
|
||||
},
|
||||
{
|
||||
"hotelId": 3,
|
||||
"hotelName": "Abuja neuer Palast",
|
||||
"description": "Kompletter Aufenthalt mit Autoservice",
|
||||
"price": 120.12,
|
||||
"imageUrl": "assets/img/huy.png",
|
||||
"rating": 4
|
||||
},
|
||||
{
|
||||
"hotelId": 4,
|
||||
"hotelName": "OUR Hotel",
|
||||
"description": "Wunderschönes Ambiente für Ihren Aufenthalt",
|
||||
"price": 135.12,
|
||||
"imageUrl": "assets/img/rat.png",
|
||||
"rating": 2.5
|
||||
}
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user