Skip to content
forked from JsDaddy/ngx-mask

Angular Plugin to make masks on form fields and html elements.

License

Notifications You must be signed in to change notification settings

hersonls/ngx-mask

This branch is 51 commits behind JsDaddy/ngx-mask:develop.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5acb93b · Jul 24, 2024
Jul 5, 2024
Aug 4, 2023
Jul 24, 2024
Jul 24, 2024
Jul 24, 2024
May 29, 2024
Jun 19, 2024
Oct 24, 2019
Oct 27, 2022
Mar 29, 2023
Mar 18, 2024
Oct 27, 2022
Oct 27, 2022
Oct 27, 2022
Jul 22, 2024
Jun 11, 2023
Apr 8, 2020
Feb 7, 2018
Mar 29, 2024
Mar 28, 2024
Jul 24, 2024
Jul 24, 2024
Oct 27, 2022
Jul 24, 2024
Jul 24, 2024
Jul 24, 2024
Jul 24, 2024
Mar 29, 2024
Jul 24, 2024
Jul 24, 2024

Repository files navigation

NGX MASK is the best directive to solve masking input with needed pattern

CI npm npm downloads

npm

GitHub contributors

GitHub stars

You can also try our NGX LOADER INDICATOR check. You can also try our NGX COPYPASTE check.

You can try live documentation with examples

Installing

Angular version 17.x.x

$ npm install --save ngx-mask

Angular version 16.x.x

$ npm install --save ngx-mask@16.4.2

Angular version 15.x.x

$ npm install --save ngx-mask@15.2.3

Angular version 14.x.x

$ npm install --save ngx-mask@14.3.3

Angular version 13.x.x or 12.x.x

$ npm install --save ngx-mask@13.2.2

Quickstart if ngx-mask version >= 15.0.0

Import ngx-mask directive, pipe and provide NgxMask providers with provideNgxMask function.

With default config options application level

bootstrapApplication(AppComponent, {
    providers: [
        (...)
        provideEnvironmentNgxMask(),
        (...)
    ],
}).catch((err) => console.error(err));

Passing your own mask config options

import { IConfig } from 'ngx-mask'

const maskConfig: Partial<IConfig> = {
  validation: false,
};

bootstrapApplication(AppComponent, {
    providers: [
        (...)
        provideEnvironmentNgxMask(maskConfig),
        (...)
    ],
}).catch((err) => console.error(err));

Using a function to configure:

const maskConfigFunction: () => Partial<IConfig> = () => {
  return {
    validation: false,
  };
};

bootstrapApplication(AppComponent, {
    providers: [
         (...)
         provideEnvironmentNgxMask(maskConfigFunction),
         (...)
],
}).catch((err) => console.error(err));

With config options feature level

@Component({
    selector: 'my-feature',
    templateUrl: './my-feature.component.html',
    styleUrls: ['./my-feature.component.css'],
    standalone: true,
    imports: [NgxMaskDirective, (...)],
    providers: [
          (...)
          provideNgxMask(),
          (...)
    ],
})
export class MyFeatureComponent {}

Then, import directive, pipe to needed standalone component and just define masks in inputs.

With Angular modules

@NgModule({
  imports: [
      NgxMaskDirective, NgxMaskPipe
  ],
  providers: [provideNgxMask()]
})

Quickstart if ngx-mask version < 15.0.0

For version ngx-mask < 15.0.0 Import ngx-mask module in Angular app.

With default mask config options

import { NgxMaskModule, IConfig } from 'ngx-mask'

export const options: Partial<null|IConfig> | (() => Partial<IConfig>) = null;

@NgModule({
  imports: [
    NgxMaskModule.forRoot(),
  ],
})

Passing in your own mask config options

import { NgxMaskModule, IConfig } from 'ngx-mask'

const maskConfig: Partial<IConfig> = {
  validation: false,
};

@NgModule({
  imports: [
    NgxMaskModule.forRoot(maskConfig),
  ],
})

Or using a function to get the config:

const maskConfigFunction: () => Partial<IConfig> = () => {
  return {
    validation: false,
  };
};

@NgModule({
  imports: [
    NgxMaskModule.forRoot(maskConfigFunction),
  ],
})

Then, just define masks in inputs.

Usage

Text documentation

Setup hooks

$ npm run init:hooks

Contributing

We would love some contributions! Check out this document to get started.

About

Angular Plugin to make masks on form fields and html elements.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.5%
  • HTML 1.8%
  • Other 1.7%