53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { Component, Injectable, Input } from "@angular/core";
|
|
import { ChildComponent } from "../Child/child.component";
|
|
import { Hotel } from "./hotel";
|
|
import { CurrencyPipe, NgIf } from "@angular/common";
|
|
import { FormsModule } from "@angular/forms";
|
|
import { StarRatingComponent } from "../star-rating/star-rating.component";
|
|
import { HttpClient } from "@angular/common/http";
|
|
|
|
@Component({
|
|
selector: 'app-hotel-item',
|
|
standalone: true,
|
|
templateUrl: './HotelItem.component.html',
|
|
imports: [ChildComponent, CurrencyPipe, FormsModule, StarRatingComponent, NgIf],
|
|
})
|
|
export class HotelItem {
|
|
|
|
@Input() public hotel!: Hotel;
|
|
public selectedLanguage?: string;
|
|
|
|
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"
|
|
}
|
|
];
|
|
}
|