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'; import { NgControl } from '@angular/forms';
@Directive({ @Directive({
selector: '[utDisableControl]' selector: '[utDisableControl]'
}) })
export class DisableControlDirective { export class DisableControlDirective implements OnChanges {
constructor(private ngControl: NgControl) {} constructor(@Self() private ngControl: NgControl) {}
@Input('utDisableControl') @Input('utDisableControl')
public set disableControl(condition: boolean) { public disableControl: boolean;
const action = !!condition ? 'disable' : 'enable';
public ngOnChanges(changes: SimpleChanges): void {
if (changes && changes['disableControl']) {
const action = !!this.disableControl ? 'disable' : 'enable';
this.ngControl.control[action](); 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