import { Directive, ElementRef, EventEmitter, Input, Output} from "@angular/core"; declare var jQuery: any; @Directive({ selector: "[autonumeric]", }) export class Autonumeric { @Input() decimalSeparator: string = "."; @Input() groupSeparator: string = ""; @Input() decimalPlaces: number= 3; @Input() value: number; @Output() valueChange = new EventEmitter(); constructor(el: ElementRef) { var that = this; jQuery(el.nativeElement).autoNumeric( 'init', { aDec: this.decimalSeparator, aSep: this.groupSeparator, mDec: this.decimalPlaces }); jQuery(el.nativeElement).on('change', function () { var newValue = parseFloat(el.nativeElement.value as string); this.value = newValue; that.valueChange.emit(newValue); }); } }