import {Component, Input, Output, EventEmitter, OnChanges, SimpleChanges} from '@angular/core'; import {FormControl} from '@angular/forms'; @Component({ selector: 'single-line-text-input-component', template: `
{{label}}
`, styles: [` .wrapper { display: flex; flex-direction: row; } .textarea-wrapper { width: 100%; } .label { font-size: 18px; color: black; } .cancel { cursor: pointer; font-size: 28px; font-weight: 500; display: flex; flex-direction: column; justify-content: center; } `] }) export class SingleLineTextInputComponent implements OnChanges { @Input() public model: string; @Input() public placeholder: string = ''; @Input() public label: string; @Input() public control: FormControl = new FormControl('', []); @Output() public modelChange: EventEmitter = new EventEmitter(); @Output() public onChange: EventEmitter = new EventEmitter(); public initialValue: string; public ngOnChanges(simpleChanges: SimpleChanges): void { if (simpleChanges['model'] && simpleChanges['model'].isFirstChange()){ this.initialValue = simpleChanges['model'].currentValue; } } public onCancel(): void { this.model = this.initialValue; this.control.markAsPristine(); } }