import { Component , OnInit } from '@angular/core' ; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' ; import { FormControl , FormGroup , Validators } from '@angular/forms' ; import { CategoryService , checkCategoryExistsValidator } from '../../../../services/category.service' ; import { ProgressSpinnerService } from '../../../../../layout/progress/progress-spinner.service' ; @ Component ( { selector : 'cmdb-add-category-modal' , templateUrl : './add-category-modal.component.html' , styleUrls : [ './add-category-modal.component.scss' ] } ) export class AddCategoryModalComponent implements OnInit { public catAddForm : FormGroup ; constructor ( public activeModal , private categoryService ) { this . catAddForm = new FormGroup ( { name : new FormControl ( '' , Validators . required ) , label : new FormControl ( '' ) } ) ; } public ngOnInit ( ) { this . name . setAsyncValidators ( checkCategoryExistsValidator ( this . categoryService ) ) ; } public get name ( ) : FormControl { return this . catAddForm . get ( 'name' ) as FormControl ; } public get label ( ) : FormControl { return this . catAddForm . get ( 'label' ) as FormControl ; } }