Skip to content

Commit

Permalink
Fixed #2632
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Aug 10, 2017
1 parent 963251a commit 0fe619f
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/app/components/inputmask/inputmask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export const INPUTMASK_VALUE_ACCESSOR: any = {
providers: [INPUTMASK_VALUE_ACCESSOR,DomHandler]
})
export class InputMask implements OnInit,OnDestroy,ControlValueAccessor {

@Input() mask: string;


@Input() type: string = 'text';

@Input() slotChar: string = '_';
Expand Down Expand Up @@ -91,6 +89,8 @@ export class InputMask implements OnInit,OnDestroy,ControlValueAccessor {

value: any;

_mask: string;

onModelChange: Function = () => {};

onModelTouched: Function = () => {};
Expand Down Expand Up @@ -128,6 +128,25 @@ export class InputMask implements OnInit,OnDestroy,ControlValueAccessor {
constructor(public el: ElementRef, public domHandler: DomHandler) {}

ngOnInit() {
let ua = this.domHandler.getUserAgent();
this.androidChrome = /chrome/i.test(ua) && /android/i.test(ua);

this.initMask();
}

@Input() get mask(): string {
return this._mask;
}

set mask(val:string) {
this._mask = val;

this.initMask();
this.writeValue('');
this.onModelChange(this.value);
}

initMask() {
this.tests = [];
this.partialPosition = this.mask.length;
this.len = this.mask.length;
Expand All @@ -138,9 +157,6 @@ export class InputMask implements OnInit,OnDestroy,ControlValueAccessor {
'*': '[A-Za-z0-9]'
};

let ua = this.domHandler.getUserAgent();
this.androidChrome = /chrome/i.test(ua) && /android/i.test(ua);

let maskTokens = this.mask.split('');
for(let i = 0; i < maskTokens.length; i++) {
let c = maskTokens[i];
Expand Down

0 comments on commit 0fe619f

Please sign in to comment.