Initial commit
This commit is contained in:
15
src/app/label.directive.ts
Normal file
15
src/app/label.directive.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Directive, HostBinding, Input, Optional } from '@angular/core';
|
||||
import { ControlContainer } from '@angular/forms';
|
||||
|
||||
@Directive({
|
||||
selector: 'span[control]'
|
||||
})
|
||||
export class LabelDirective {
|
||||
@Input() control: string = ""
|
||||
constructor(@Optional() private parent: ControlContainer) { }
|
||||
|
||||
@HostBinding('textContent')
|
||||
get controlValue() {
|
||||
return this.parent ? this.parent.control?.get(this.control)?.value : ""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user