This input sanitization directive prevents the user from typing invalid characters into your inputs. It will later be extended to support masking, e.g. (xxx)xxx-xxxx for phone numbers.
npm install angular2-input-masksSupports 2.0.0.
javascript
import {Component} from '@angular/core';
import {MaskType, CustomMask, CustomMaskConfig, CustomMaskResult} from 'angular2-input-masks';@Component({
selector: 'my-component',
template:
})
export class MyComponent {
MaskType = MaskType;
// anything matching this regex will be replaced. remember to use the negate flag (^) when whitelisting
customRegex = /[^a-z0-9!%]/;
customMask:CustomMask = (config:CustomMaskConfig) => {
let result:CustomMaskResult = {
maskedValue: config.initialValue.toUpperCase(),
newCaretPosition: config.currentCaretPosition
};
return result;
}
}// remember to import MaskingModule into your NgModule!
``---
Under Development