mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
fix(angular): resolve issue when not using ngModel on components
This commit is contained in:
@ -62,7 +62,12 @@ export class ValueAccessor implements ControlValueAccessor, AfterViewInit, OnDes
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
const ngControl = this.injector.get<NgControl>(NgControl as Type<NgControl>);
|
let ngControl;
|
||||||
|
try {
|
||||||
|
ngControl = this.injector.get<NgControl>(NgControl as Type<NgControl>);
|
||||||
|
} catch { /* No FormControl or ngModel binding */ }
|
||||||
|
|
||||||
|
if (!ngControl) { return; }
|
||||||
|
|
||||||
// Listen for changes in validity, disabled, or pending states
|
// Listen for changes in validity, disabled, or pending states
|
||||||
if (ngControl.statusChanges) {
|
if (ngControl.statusChanges) {
|
||||||
|
Reference in New Issue
Block a user