简体   繁体   English

使用打字稿+角度2的时刻

[英]Moment with typescript+angular2

i using the moment js library and everything okay except one thing. 我使用时刻js库和一切都没关系,除了一件事。

Using initialization like this don't look good. 像这样使用初始化看起来不太好。 I don't want import everything from 'moment' 我不希望从'时刻'导入所有东西

import * as moment  from 'moment/moment';

One place where i use moment it: 我用它的一个地方:

        var differenceBeteweenDates = moment(toDate, this.dateFormat)
            .diff(moment(fromDate, this.dateFormat),
            "days");

i need Import only necessary modules/functions. 我需要只导入必要的模块/功能。 How i can do it? 我怎么能这样做?

 ps: import { Moment }  from 'moment/moment'; - don't contain all things what i need

import { Moment, fn, utc as moment } from 'moment/moment'; and use moment. 并使用moment. or moment() what you need 或者moment()你需要什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM