import { Component, OnInit, Input, OnChanges, Output, EventEmitter } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; @Component({ selector: 'hbor-vrijeme', templateUrl: './vrijeme.component.html', styleUrls: ['./vrijeme.component.css'] }) export class VrijemeComponent implements OnInit, OnChanges { @Output() onVrijemeChange: EventEmitter = new EventEmitter(); @Input() disabled = false; @Input() placeholder = 'Vrijeme'; @Input() floatLabel = 'auto'; @Input() errorMessageRequired = 'Polje je obavezno'; @Input() errorMessageCustom = ''; @Input() hborFormControl: FormControl; @Input() width = 180; @Input() maxlength = '999'; public mask = [/[0-2]/, /[0-9]/, ':', /[0-5]/, /[0-9]/] constructor() { } ngOnInit() { if (this.hborFormControl === undefined) { this.hborFormControl = new FormControl([{ value: '', disabled: this.disabled }]); } this.hborFormControl.valueChanges.subscribe(() => { this.onVrijemeChange.emit(this.hborFormControl.value) }) } ngOnChanges() { } }