import { Component, OnInit, Input, Output, EventEmitter, OnChanges } from '@angular/core'; import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms'; @Component({ selector: 'hbor-tecaj', templateUrl: './tecaj.component.html', styleUrls: ['./tecaj.component.css'] }) export class TecajComponent implements OnInit, OnChanges { @Output() onTecajChange: EventEmitter = new EventEmitter(); @Input() disabled = false; @Input() placeholder = 'Tečaj'; @Input() floatLabel = 'auto'; @Input() errorMessageRequired = 'Polje je obavezno'; @Input() errorMessageCustom = ''; @Input() hborFormControl: FormControl; @Input() width = 180; @Input() max = 99999; @Input() min = -99999; mask = { prefix: '', precision: 6, thousands: '.', decimal: ',', allowNegative: false }; constructor() { } ngOnInit() { if (this.hborFormControl === undefined) { this.hborFormControl = new FormControl([{ value: '', disabled: this.disabled }]); } this.hborFormControl.valueChanges.subscribe(() => { this.onTecajChange.emit(this.hborFormControl.value) }) } ngOnChanges() { } }