我一直在尝试在angular4应用程序中实现moneyjs
我希望在像这样的组件中使用
import * as fx from 'money/money.js';
我感到困惑的是在哪里配置汇率
fx.rates = {
GBP: 0.6,
USD: 1
};
fx.base = USD;
我可以在构建我的组件时完成此操作,但我不想在单个组件中重复配置,因此应在主模块中配置 app.module.ts 在我的情况下,我使用 angular-cli
答案 0 :(得分:0)
我认为您最好创建service
money.service.ts
,并在该服务constructor
内完成所有配置。然后在需要时注入该服务。