Plunker add angular2-moment package into angular2 app

235 views Asked by At

Using the default templates provided by Plunker to create angular2 apps, I've been trying to import angular2-moment into my angular2 app on Plunker.

import * as moment from 'moment';

this is how my plunker config.js looks like

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:[email protected]',
    'angular2-moment': 'npm:[email protected]',
    'typescript': 'npm:[email protected]/lib/typescript.js'
  },
  //packages defines our app package
  packages: {
    'app': {
      main: './main.ts',
      defaultExtension: 'ts'
    },
    'rxjs': {
      defaultExtension: 'js'
    },
    'angular2-moment': { 
      defaultExtension: 'js'
    }
  }
});

What am I missing here?

1

There are 1 answers

0
user6801750 On

Try import like below:

import {MomentModule} from 'angular2-moment';

Reference: https://github.com/urish/angular2-moment