import { Component, OnInit, EventEmitter, Output, Input } from '@angular/core'; import { FormControl } from '@angular/forms'; @Component({ selector: 'hbor-input', templateUrl: './input.component.html', styleUrls: ['./input.component.css'] }) export class InputComponent implements OnInit { @Output() onInputChange: EventEmitter = new EventEmitter(); @Input() disabled = false; @Input() placeholder = 'Input'; @Input() floatLabel = 'auto'; @Input() errorMessageRequired = 'Polje je obavezno'; @Input() errorMessageCustom = ''; @Input() hborFormControl: FormControl; @Input() width = 180; @Input() maxlength = '999'; constructor() { } ngOnInit() { if (this.hborFormControl === undefined) { this.hborFormControl = new FormControl([{ value: '', disabled: this.disabled }]); } this.hborFormControl.valueChanges.subscribe(() => { this.onInputChange.emit(this.hborFormControl.value) }) } ngOnChanges() { } }