cesarrew / ng2-currency-mask

A very simple currency mask directive that allows using a number attribute with the ngModel.
MIT License
235 stars 116 forks source link

TypeError: Cannot set property 'align' of undefined #123

Open diegoichinose opened 5 years ago

diegoichinose commented 5 years ago

Hello, Currently I am having the following error "TypeError: Cannot set property 'align' of undefined" as I run karma test with any components that make use of the CurrencyMaskModule.

I am using Angular 6 and the v5.3.1 of ng2-currency-mask.

The error disappears as I comment line 33 of the currency-mask.directive.js this.elementRef.nativeElement.style.textAlign = this.options.align ? this.options.align : this.optionsTemplate.align;

This issue only appears with ng test but nothing wrong with the ng serve. Any ideas?

diegoichinose commented 5 years ago

This could literally be solved by simply changing this (line 33 of currency-mask.directive.js):

    this.elementRef.nativeElement.style.textAlign = this.options.align ? this.options.align : this.optionsTemplate.align;

To this:

    this.elementRef.nativeElement.style.textAlign = this.options ? this.options.align : this.optionsTemplate.align;

I would appreciate the heck out of you if you did this little change in the next update.

Cheers!