Compare commits
2 commits
c0bc95493a
...
374d4f756a
Author | SHA1 | Date | |
---|---|---|---|
374d4f756a | |||
ee7a4c995f |
2 changed files with 8 additions and 0 deletions
|
@ -1,4 +1,5 @@
|
||||||
@if (hotel != null) {
|
@if (hotel != null) {
|
||||||
<app-hotel-item [hotel]="hotel" [isDetail]="true"></app-hotel-item>
|
<app-hotel-item [hotel]="hotel" [isDetail]="true"></app-hotel-item>
|
||||||
<app-hotel-form [hotel]="hotel"></app-hotel-form>
|
<app-hotel-form [hotel]="hotel"></app-hotel-form>
|
||||||
|
<button (click)="delete()">DELETE</button>
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,13 @@ export class HotelDetailsComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private http: HttpClient, private router: Router) { }
|
constructor(private route: ActivatedRoute, private http: HttpClient, private router: Router) { }
|
||||||
|
|
||||||
|
delete(): void {
|
||||||
|
if (confirm("Are u sure u want to delete this hotel")) {
|
||||||
|
this.http.delete<Hotel>("/api/hotels/" + this.route.snapshot.paramMap.get("id")).subscribe();
|
||||||
|
this.router.navigate(["/"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const routeParams = this.route.snapshot.paramMap;
|
const routeParams = this.route.snapshot.paramMap;
|
||||||
const hotelId = routeParams.get("id");
|
const hotelId = routeParams.get("id");
|
||||||
|
|
Loading…
Add table
Reference in a new issue