30 lines
983 B
TypeScript
30 lines
983 B
TypeScript
|
import { HttpClient } from '@angular/common/http';
|
||
|
import { Component, OnInit } from '@angular/core';
|
||
|
import { ActivatedRoute } from '@angular/router';
|
||
|
import { Hotel } from '../HotelItem/hotel';
|
||
|
import { CurrencyPipe } from '@angular/common';
|
||
|
import { StarRatingComponent } from '../star-rating/star-rating.component';
|
||
|
import { HotelItem } from '../HotelItem/HotelItem.component';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'app-hotel-details',
|
||
|
standalone: true,
|
||
|
imports: [CurrencyPipe, StarRatingComponent, HotelItem],
|
||
|
templateUrl: './hotel-details.component.html',
|
||
|
styleUrl: './hotel-details.component.css'
|
||
|
})
|
||
|
export class HotelDetailsComponent implements OnInit {
|
||
|
public hotel: any;
|
||
|
|
||
|
constructor(private route: ActivatedRoute, private http: HttpClient) { }
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
const routeParams = this.route.snapshot.paramMap;
|
||
|
const hotelId = routeParams.get("id");
|
||
|
|
||
|
this.http.get<Hotel>("api/hotels/" + hotelId).subscribe(res => {
|
||
|
this.hotel = res;
|
||
|
});
|
||
|
}
|
||
|
}
|