Last active
May 9, 2019 08:25
-
-
Save armanozak/a4102e39b640fdf84544a9d10e674dc0 to your computer and use it in GitHub Desktop.
An Abstract Input Component Extending Abstract NgModel Component #blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, EventEmitter, Input, Output } from '@angular/core'; | |
import { AbstractNgModelComponent } from './ng-model.component'; | |
@Component({ template: '' }) | |
export class AbstractInputComponent extends AbstractNgModelComponent<string> { | |
@Input() | |
readonly: boolean = false; | |
@Input() | |
required: boolean = false; | |
@Input() | |
placeholder: string = ''; | |
@Input() | |
type: string = 'text'; | |
@Output() | |
onBlur = new EventEmitter<void>(); | |
@Output() | |
onFocus = new EventEmitter<void>(); | |
get inputReadonly(): boolean { | |
return this.readonly || typeof this.readonly !== 'boolean'; | |
} | |
get inputRequired(): boolean { | |
return this.required || typeof this.required !== 'boolean'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment