diff --git a/src/app/hotel/add-tag.component.ts b/src/app/hotel/add-tag.component.ts deleted file mode 100644 index 56b86c2..0000000 --- a/src/app/hotel/add-tag.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {Component, Input} from "@angular/core"; -import {NgForOf} from "@angular/common"; -import {TagComponent} from "./tag.component"; -import { - AbstractControl, - ControlContainer, - FormArray, - FormControl, - FormGroupDirective, - Validators -} from "@angular/forms"; - - -@Component({ - selector: 'app-add-tag', - standalone: true, - template: ` - `, - viewProviders: [ - { - provide: ControlContainer, - useExisting: FormGroupDirective - } - ], - imports: [ - NgForOf, - TagComponent - ] -}) -export class AddTagComponent { - - @Input() - form!: FormArray; - - addTag() { - this.form.push(new FormControl('', [Validators.required])); - } - - deleteTag(id: AbstractControl) { - this.form.removeAt(this.form.controls.indexOf(id)); - } -} diff --git a/src/app/hotel/create-hotel.component.ts b/src/app/hotel/create-hotel.component.ts index 59806fc..00924b3 100644 --- a/src/app/hotel/create-hotel.component.ts +++ b/src/app/hotel/create-hotel.component.ts @@ -2,6 +2,7 @@ import {Component, inject} from "@angular/core"; import {Hotel} from "./hotel"; import {HotelService} from "../service/hotel.service"; import {EditHotelComponent} from "./edit-hotel.component"; +import {Router} from "@angular/router"; @Component({ @@ -18,7 +19,11 @@ export class CreateHotelComponent { hotelService: HotelService = inject(HotelService); + router: Router = inject(Router); + create(hotel: Hotel) { - this.hotelService.createHotel(hotel).subscribe() + this.hotelService.createHotel(hotel).subscribe(); + + this.router.navigate(['/hotels']); } } diff --git a/src/app/hotel/edit-hotel.component.ts b/src/app/hotel/edit-hotel.component.ts index c19f70b..e42a8c7 100644 --- a/src/app/hotel/edit-hotel.component.ts +++ b/src/app/hotel/edit-hotel.component.ts @@ -10,7 +10,6 @@ import { } from "@angular/forms"; import {Hotel} from "./hotel"; import {RouterLink} from "@angular/router"; -import {AddTagComponent} from "./add-tag.component"; import {NgForOf} from "@angular/common"; import {TagComponent} from "./tag.component"; @@ -21,7 +20,6 @@ import {TagComponent} from "./tag.component"; FormsModule, ReactiveFormsModule, RouterLink, - AddTagComponent, NgForOf, TagComponent ],