Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setValue being called before inputHandler gets initialized #159

Open
williamxsp opened this issue May 21, 2021 · 0 comments
Open

setValue being called before inputHandler gets initialized #159

williamxsp opened this issue May 21, 2021 · 0 comments

Comments

@williamxsp
Copy link

williamxsp commented May 21, 2021

I have a custom input that im trying to implement this directive. It works but I got this error message at the console.

ERROR TypeError: Cannot read property 'setValue' of undefined
at CurrencyMaskDirective.writeValue (currency-mask.directive.ts:144)
at CurrencyInputComponent.writeValue (control-value-accessor-connector.ts:26)

The problem is here:

writeValue(value: number): void {
        this.inputHandler.setValue(value);
    }

looks like this function is beeing fired before inputHandler gets initialized:

ngOnInit() {
        this.inputHandler = new InputHandler(this.elementRef.nativeElement, (<any>Object).assign({}, this.optionsTemplate, this.options));
    }

Ive created an stackblitz with the problem:
https://stackblitz.com/edit/angular-ivy-ycax21?file=src%2Fapp%2Fapp.component.ts

Do you have any idea whats going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant