Using moment.js in Angular 2 typescript application

后端 未结 5 2154
名媛妹妹
名媛妹妹 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 06:51

    Also I found this: Install Moment.js using NPM:

    npm install moment
    

    Add it to your SystemJS configuration:

    map: {
      'angular2': 'node_modules/angular2',
      'rxjs': 'node_modules/rxjs',
      'moment': 'node_modules/moment/moment'
    }
    

    You also need the interface: tsd install moment --save and then add:

    /// 
    import * as moment from 'moment';
    

提交回复
热议问题