Commit 982aa95c authored by Ryan Diehl's avatar Ryan Diehl

fix(form): support ivy in DisableControlDirective

parent ced5f7c0
Pipeline #106155 passed with stages
in 6 minutes and 29 seconds
import { Directive, Input } from '@angular/core';
import { Directive, Input, OnChanges, Self, SimpleChanges } from '@angular/core';
import { NgControl } from '@angular/forms';
@Directive({
selector: '[utDisableControl]'
})
export class DisableControlDirective {
constructor(private ngControl: NgControl) {}
export class DisableControlDirective implements OnChanges {
constructor(@Self() private ngControl: NgControl) {}
@Input('utDisableControl')
public set disableControl(condition: boolean) {
const action = !!condition ? 'disable' : 'enable';
public disableControl: boolean;
public ngOnChanges(changes: SimpleChanges): void {
if (changes && changes['disableControl']) {
const action = !!this.disableControl ? 'disable' : 'enable';
this.ngControl.control[action]();
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment