Skip to content

Commit a730ad6

Browse files
committed
fix(forms): add setDisabledState handler for base value accessor
enables [disabled] for form controls
1 parent 5d2e4e0 commit a730ad6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: nativescript-angular/value-accessors/base-value-accessor.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ControlValueAccessor } from "@angular/forms";
2+
import { View } from "tns-core-modules/ui/core/view";
23

3-
export class BaseValueAccessor<TView> implements ControlValueAccessor {
4+
export class BaseValueAccessor<TView extends View> implements ControlValueAccessor {
45
private pendingChangeNotification: number = 0;
56
onChange = (_) => { };
67
onTouched = () => {};
@@ -19,7 +20,13 @@ export class BaseValueAccessor<TView> implements ControlValueAccessor {
1920
};
2021
}
2122

22-
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
23+
registerOnTouched(fn: () => void): void {
24+
this.onTouched = fn;
25+
}
26+
27+
setDisabledState(isDisabled: boolean): void {
28+
this.view.isEnabled = !isDisabled;
29+
};
2330

2431
writeValue(_: any) { }
2532
}

0 commit comments

Comments
 (0)