Skip to content

Instantly share code, notes, and snippets.

@argentinaluiz
Created April 3, 2019 20:17
Show Gist options
  • Save argentinaluiz/754c838c76891f8de449c16ae79859b1 to your computer and use it in GitHub Desktop.
Save argentinaluiz/754c838c76891f8de449c16ae79859b1 to your computer and use it in GitHub Desktop.
import * as $ from 'jquery';
import 'jquery-mask-plugin/dist/jquery.mask';
import {Directive, ElementRef} from '@angular/core';
@Directive({
selector: '[appMaskNumber]'
})
export class MaskNumberDirective {
constructor(private elementRef: ElementRef) {
this.applyMask();
}
applyMask(){
const nativeElement = this.elementRef.nativeElement; //DOM
$(nativeElement).find('input').mask('#.##0,00', {reverse: true}); //ion-input ->input
}
}
<ion-input appMaskNumber>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment