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 {Hotel} from "./hotel";
|
||||||
import {HotelService} from "../service/hotel.service";
|
import {HotelService} from "../service/hotel.service";
|
||||||
import {EditHotelComponent} from "./edit-hotel.component";
|
import {EditHotelComponent} from "./edit-hotel.component";
|
||||||
|
import {Router} from "@angular/router";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -18,7 +19,11 @@ export class CreateHotelComponent {
|
|||||||
|
|
||||||
hotelService: HotelService = inject(HotelService);
|
hotelService: HotelService = inject(HotelService);
|
||||||
|
|
||||||
|
router: Router = inject(Router);
|
||||||
|
|
||||||
create(hotel: Hotel) {
|
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";
|
} from "@angular/forms";
|
||||||
import {Hotel} from "./hotel";
|
import {Hotel} from "./hotel";
|
||||||
import {RouterLink} from "@angular/router";
|
import {RouterLink} from "@angular/router";
|
||||||
import {AddTagComponent} from "./add-tag.component";
|
|
||||||
import {NgForOf} from "@angular/common";
|
import {NgForOf} from "@angular/common";
|
||||||
import {TagComponent} from "./tag.component";
|
import {TagComponent} from "./tag.component";
|
||||||
|
|
||||||
@ -21,7 +20,6 @@ import {TagComponent} from "./tag.component";
|
|||||||
FormsModule,
|
FormsModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
AddTagComponent,
|
|
||||||
NgForOf,
|
NgForOf,
|
||||||
TagComponent
|
TagComponent
|
||||||
],
|
],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user