GithubHelp home page GithubHelp logo

g-serghei / text-mask Goto Github PK

View Code? Open in Web Editor NEW

This project forked from text-mask/text-mask

0.0 2.0 0.0 2.63 MB

Input mask for React, Angular, Ember, & plain JavaScript

Home Page: https://text-mask.github.io/text-mask/

Shell 0.90% JavaScript 90.85% HTML 3.41% TypeScript 4.85%

text-mask's Introduction

Angular 2 Input Mask

This Angular 2 Directive is also compatible with Ionic 2 ion-input.

Getting started

First, install it.

npm i angular2-text-mask --save

Then, import it into your @NgModule and declare it:

import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import MaskedInput from 'angular2-text-mask'

@NgModule({
  imports: [FormsModule],
  declarations: [MaskedInput]
})
export class TextMaskModule {}

Then, use it in your component:

@Component({
  selector: 'app',
  template: `
    <input [textMask]="{mask: mask}" [(ngModel)]="myModel" type="text"/>
  `
})
export class AppComponent {
  public myModel = ''
  public mask = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]
}

Documentation

As you can see in the code above, you are passing an object to the textMask directive.

๐Ÿ“ For more information about the values that the textMask object accepts, see this page.

Other use-cases

Unmasking the value that is stored in the model

Text Mask does not provide an option to unmask the model before storing it. You can sanitize the model on your side. See here for details.

Example

To see an example of the code running, follow these steps:

  1. Clone the repo, git clone [email protected]:text-mask/text-mask.git
  2. cd text-mask
  3. npm install
  4. npm run angular2:dev
  5. Open http://localhost:3000

The code of the example is in angular2/example.

Contributing

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

License

Public domain - CC0 1.0 Universal

text-mask's People

Contributors

msafi avatar greenkeeperio-bot avatar browniefed avatar andyrue avatar lozjackson avatar g-serghei avatar ihadeed avatar sky-coding avatar billcolumbia avatar kevgathuku avatar semirturgay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.