2.0.0 • Published 1 year ago

ngx-pattern v2.0.0

Weekly downloads
36
License
MIT
Repository
github
Last release
1 year ago

ngx-pattern

ngx-pattern License

ngx-pattern is a small directive you can use to filter allowed input with regular expressions.

Check examples here.

Which version to pick

The library has several versions compiled for different angular versions. Make sure to pick the correct one

Angular Versionngx-pattern VersionEngine Used
< 9<= 0.2.1View Engine
>= 9 < 12^1.0.0View Engine
>= 12^2.0.0Partial-Ivy

Installation

To use ngx-pattern in your project install it via:

  • NPM

    npm install ngx-pattern --save
  • Yarn

    yarn add ngx-pattern

After installing, include NgxPatternModule in your application module like:

  import { NgModule } from '@angular/core';
  import { BrowserModule } from '@angular/platform-browser';
  import { NgxDatatableModule } from 'ngx-pattern';

  import { AppComponent } from './app.component';

  @NgModule({
    declarations: [AppComponent],
    imports: [NgxPattern, BrowserModule],
    bootstrap: [AppComponent]
  })
  export class AppModule { }

Usage

  • You can set up the pattern using a string

    <input type="text" [(ngModel)]="lowerCaseText" ngxPattern="[a-z]*">
    <input type="text" [(ngModel)]="lowerCaseText" [ngxPattern]="'[a-z]*'">
  • Or a RegEx

    numbersOnly = /^[0-9]*$/;
    
    ...
    
    <input type="text" [ngxPattern]="numbersOnly">

Changelog

2.0.0
  • Partial-Ivy compilation for better compatibility with modern Angular
  • Minimum Angular version changed to 12+
1.0.0
  • Minimum Angular version changed to 9+
  • Update incorrect keydown handling of special keys
  • Improved unit tests coverage
  • Project switched to strict mode
0.2.1
  • Support for Angular 12
  • Working detection on Android mobile browser
0.1.3
  • support for Angular 10 and 11
0.1.2
  • updated readme
0.1.0
  • string and regex pattern support
2.0.0

1 year ago

1.0.0

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.3

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago