Using moment.js in Angular 2 typescript application

后端 未结 5 2123
名媛妹妹
名媛妹妹 2021-02-20 06:21

I\'m struggling in using moment.js library inside an Angular 2 Typescript app. Even after reading the answer to this question I can\'t get it to work.

This is what I did

5条回答
  •  难免孤独
    2021-02-20 07:02

    From your index.html add

     
    

    In your component use:

    declare var moment: any;
    ...
    
    this.startDate = moment().subtract(15, 'days').format('DD-MM-YYYY');
    this.endDate = moment().format('DD-MM-YYYY');
    

提交回复
热议问题