angular-hotel-manager/src/app/HotelItem/HotelItem.component.ts
2024-11-26 09:37:20 +01:00

53 lines
1.2 KiB
TypeScript

import { Component, Input } from "@angular/core";
import { Hotel } from "./hotel";
import {CurrencyPipe, NgForOf, NgIf} from "@angular/common";
import { FormsModule } from "@angular/forms";
import { RouterLink } from "@angular/router";
@Component({
selector: 'app-hotel-item',
standalone: true,
templateUrl: './HotelItem.component.html',
imports: [CurrencyPipe, FormsModule, NgIf, RouterLink, NgForOf],
})
export class HotelItem {
@Input() public hotel!: Hotel;
public selectedLanguage?: string;
@Input() public isDetail: boolean = false;
public languageChange(lang: string) {
this.selectedLanguage = lang;
console.log(this.selectedLanguage);
}
public getCurrencyCode(langCode: string | undefined): string {
if (!langCode) return '';
for (let language of this.langs) {
if (language.code === langCode) {
return language.currency;
}
}
return '';
}
public langs = [
{
"lang": "en",
"code": "en-US",
"currency": "USD"
},
{
"lang": "cn",
"code": "cn-CN",
"currency": "CNY"
},
{
"lang": "de",
"code": "de-DE",
"currency": "EUR"
}
];
}