Ich habe moment.js mit npm install moment --save
installiert und es befindet sich jetzt in meinem Ordner node_modules, aber ich weiß nicht, wie ich es in meiner App referenzieren soll.Wie wird auf ein Drittanbieter-Npm-Modul verwiesen?
Q) Wie kann ich moment.js in meiner Ionic 2 App verwenden, wenn ich sie mit npm installiert habe?
Hier eine gekürzte Version meiner app.ts:
import {App, IonicApp, Platform, Modal, Events, Alert, MenuController} from 'ionic-angular';
import {Type} from 'angular2/core';
import {OnInit, OnDestroy} from 'angular2/core';
// native stuff
import {Keyboard} from 'ionic-native';
// tried this but it can't find the module
//import {moment} from 'moment';
@App({
templateUrl: 'build/app.html',
config: {}, // http://ionicframework.com/docs/v2/api/config/Config/
providers: []
})
class MyApp {
isLoadingData: boolean = false;
rootPageToExitOn: string;
rootPage: Type;
pages: Array<{icon: string, title: string, component: Type}>;
showMenu: boolean;
constructor(
private app: IonicApp,
private platform: Platform,
private menu: MenuController,
private _events: Events
) {
this.initializeApp();
// how to use moment() here ...?
}
}
danke, aber die Typisierungen Installation löst nicht das Problem, das tatsächliche Knotenmodul in die Seite aufzunehmen. Das alles hindert TypeScript daran, sich zu übergeben. – Dave