ValidationHelper.ts
declare var numeral: any;
export class ValidationHelper {
constructor() {
}
//---------------------------CustomCDBL----------------------------------
CustomCDBL(val: any) {
if (val == undefined) {
return 0;
}
else if (val == null) {
return 0;
}
else if (val == "") {
return 0;
}
else {
var newVal = numeral(val).format('0.00');
return Number(newVal);
}
}
}
Webpack.config.js
new webpack.ProvidePlugin({
numeral: 'numeral',
ValidationHelper: path.resolve(__dirname, './src/app/_general/ValidationHelper')
我想使用providerplugin将我的助手类“ ValidationHelper.ts”提供给其他模块,但是我的函数未执行并显示错误。
调用函数时Chrome中出现错误。
*ERROR TypeError: ValueHelper.CustomString is not a function*