【问题标题】:Plunker add angular2-moment package into angular2 appPlunker 将 angular2-moment 包添加到 angular2 应用程序中
【发布时间】:2016-12-30 00:21:54
【问题描述】:

使用 Plunker 提供的默认模板来创建 angular2 应用程序,我一直在尝试将 angular2-moment 导入到我在 Plunker 上的 angular2 应用程序中。

import * as moment from 'moment';

这就是我的 plunker config.js 的样子

System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
    emitDecoratorMetadata: true
  },
  paths: {
    'npm:': 'https://npmcdn.com/'
  },
  //map tells the System loader where to look for things
  map: {     
    'app': './src',
    ....other angular2 packages work fine...
    'rxjs': 'npm:rxjs',
    'moment': 'npm:moment@2.16.0',
    'angular2-moment': 'npm:angular2-moment@1.0.0',
    'typescript': 'npm:typescript@2.0.2/lib/typescript.js'
  },
  //packages defines our app package
  packages: {
    'app': {
      main: './main.ts',
      defaultExtension: 'ts'
    },
    'rxjs': {
      defaultExtension: 'js'
    },
    'angular2-moment': { 
      defaultExtension: 'js'
    }
  }
});

我在这里错过了什么?

【问题讨论】:

    标签: angular plunker angular2-moment


    【解决方案1】:

    尝试如下导入:

    import {MomentModule} from 'angular2-moment';
    

    参考: https://github.com/urish/angular2-moment

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-21
      相关资源
      最近更新 更多