import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; import { Component, OnInit, Input, OnChanges, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'hbor-datum', templateUrl: './datum.component.html', styleUrls: ['./datum.component.css'] }) export class DatumComponent implements OnInit, OnChanges { @Output() onDatumPicked: EventEmitter = new EventEmitter(); @Input() disabled = false; @Input() placeholder = 'Datum'; @Input() floatLabel = 'auto'; @Input() errorMessageRequired = 'Polje je obavezno'; @Input() customErrorMessage; @Input() hborFormControl: FormControl; @Input() width = 180; constructor() { } ngOnInit() { if (this.hborFormControl === undefined) { this.hborFormControl = new FormControl([{ value: '', disabled: this.disabled }]); } this.hborFormControl.valueChanges.subscribe(() => { this.onDatumPicked.emit(this.hborFormControl.value); }) } ngOnChanges() { } onChange(event) { this.onDatumPicked.emit(event); } }