minor changes
This commit is contained in:
parent
fbc277cdef
commit
f0c62cc586
@ -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));
|
||||
}
|
||||
}
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user