Reputation: 2256
I am trying to use the ngx-mask npm package to work. The instructions are as follow:
Package found here: https://www.npmjs.com/package/ngx-mask
import {NgxMaskModule} from 'ngx-mask'
export const options: Partial<IConfig> | (() => Partial<IConfig>);
@NgModule({
(...)
imports: [
NgxMaskModule.forRoot(options)
]
(...)
})
But I am getting an error on the second line:
export const options: Partial<IConfig> | (() => Partial<IConfig>);
The error says "const options" declaration must be initialized. What do I initialized it to?
Upvotes: 2
Views: 9053
Reputation: 179
I had the same problem and I decided to update the import form in app.module.ts as per the new guidance:
import { NgxMaskDirective, NgxMaskPipe, provideNgxMask } from 'ngx-mask';
imports: [
[...]
NgxMaskDirective,
NgxMaskPipe
],
providers: [
provideNgxMask()
],
Since ng14 and not in ng15 we have changes in API that we described in https://github.com/JsDaddy/ngx-mask
Please check this example:
Upvotes: 1
Reputation: 151
change
import { NgxMaskModule} from 'ngx-mask';
to
import { NgxMaskModule, IConfig } from 'ngx-mask';
Upvotes: 0
Reputation: 443
you need to initialize to null since it is a interface
import { NgxMaskModule, IConfig } from 'ngx-mask';
export const options: Partial<IConfig> | (() => Partial<IConfig>) = null;
Upvotes: 1
Reputation: 358
In your app.module.ts try like this:
import { NgxMaskModule, IConfig } from 'ngx-mask';
export let options: Partial | (() => Partial);
@NgModule({
imports: [
NgxMaskModule.forRoot(options)],
}
})
Upvotes: 0