minor changes

This commit is contained in:
Constantin Simonis 2024-12-03 08:33:44 +01:00
parent fbc277cdef
commit f0c62cc586
No known key found for this signature in database
GPG Key ID: 758DD9C506603183
3 changed files with 6 additions and 45 deletions

View File

@ -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));
}
}

View File

@ -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']);
}
}

View File

@ -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
],