【发布时间】:2017-11-30 05:47:25
【问题描述】:
我在表单内的输入中使用了maskMoney jquery 插件。当我想从那些输入字段中获取数据时,它是空的!
这是我的 MaskMoney 指令:
import {Directive, ElementRef} from "@angular/core";
declare var $: any;
@Directive({
selector: '[money]'
})
export class CurrencyMaskDirective {
constructor(public el: ElementRef) {
let native = el.nativeElement;
$(native).maskMoney({
suffix: " $",
thousands: '،',
decimal: '',
precision: 3,
affixesStay: false
});
}
}
这是我的表格:
<form role="form" #f="ngForm" (ngSubmit)="addcharge(f)" novalidate>
<input type="text" name="value" #value="ngModel" ngModel money>
</form>
// in ts file
addcharge(g) {
console.log(g.value);
}
当我记录控制台中的值是空的!如何正确地从该输入中获取价值?
谢谢。
【问题讨论】: