import { Component, OnInit, Input, AfterViewChecked, AfterContentChecked, Output, EventEmitter, OnChanges } from '@angular/core'; import { FormGroup, Validators, FormBuilder, FormControl, AbstractControl } from '@angular/forms'; @Component({ selector: 'hbor-tekst', templateUrl: './tekst.component.html', styleUrls: ['./tekst.component.css'] }) export class TekstComponent implements OnInit, OnChanges { @Output() onTekstChange: EventEmitter = new EventEmitter(); @Input() disabled = false; @Input() placeholder = 'Tekst'; @Input() floatLabel = 'auto'; @Input() errorMessageRequired = 'Polje je obavezno'; @Input() errorMessageCustom = ''; @Input() hborFormControl: FormControl; @Input() width = 180; @Input() maxlength = '999'; @Input() matAutosizeMaxRows = 10; @Input() matAutosizeMinRows = 1; constructor() { } ngOnInit() { if (this.hborFormControl === undefined) { this.hborFormControl = new FormControl([{ value: '', disabled: this.disabled }]); } this.hborFormControl.valueChanges.subscribe(() => { this.onTekstChange.emit(this.hborFormControl.value) }) } ngOnChanges() { } }