import { Component , EventEmitter , OnDestroy , OnInit , Output } from '@angular/core' ; import { FormControl , FormGroup } from '@angular/forms' ; import { Subscription } from 'rxjs' ; @ Component ( { selector : 'cmdb-import-config' , templateUrl : './import-config.component.html' , styleUrls : [ './import-config.component.scss' ] } ) export class ImportConfigComponent implements OnInit , OnDestroy { @ Output ( ) public configChange : EventEmitter < any > ; private configChangeSubscription : Subscription ; public configForm : FormGroup ; constructor ( ) { this . configChange = new EventEmitter < any > ( ) ; this . configChangeSubscription = new Subscription ( ) ; this . configForm = new FormGroup ( { start_element : new FormControl ( 0 ) , max_elements : new FormControl ( 0 ) , overwrite_public : new FormControl ( true ) } ) ; } public ngOnInit ( ) { this . configChange . emit ( this . configForm . getRawValue ( ) ) ; this . configChangeSubscription = this . configForm . valueChanges . subscribe ( ( ) => { this . configChange . emit ( this . configForm . getRawValue ( ) ) ; } ) ; } public ngOnDestroy ( ) { this . configChangeSubscription . unsubscribe ( ) ; } }