@engie-group/fluid-design-system-angular
Version:
Fluid Design System Angular
44 lines (36 loc) • 1.06 kB
text/typescript
import {Directive, ElementRef, HostBinding} from '@angular/core';
import {Utils} from '../../utils/utils.util';
export class FormFieldDirective {
class = 'nj-form-item__field';
constructor(private el: ElementRef) {
this.setPlaceholder();
}
private setPlaceholder() {
if (this.tagName.toLowerCase() === 'select') {
return;
}
const placeholder = this.el?.nativeElement?.placeholder;
this.el.nativeElement.placeholder = Utils.isUndefinedOrNull(placeholder) || placeholder?.trim() === ''
? ' '
: placeholder;
}
get type() {
return this.el?.nativeElement?.type;
}
set type(value: string) {
if (this.el?.nativeElement) {
this.el.nativeElement.type = value;
}
}
get tagName() {
return this.el?.nativeElement?.tagName;
}
get element() {
return this.el?.nativeElement;
}
}