Ich arbeite an der Verwendung moment.js with typescript
. Ich lief die folgenden BefehleIonic 2 Moment JS mit Moment TimeZones
npm install moment-timezone --save
npm install @types/moment @types/moment-timezone --save
aber aus irgendeinem Grund in der formattime
Funktion, ist zur Zeit nicht definiert. Ich bekomme keine Fehler von meiner IDE in Bezug auf meinen Import Moment und ich kann sehen, moment
und moment-timezone
sind in der npm
Ordner. Ich bin durch den Post gekrochen, aber ich sehe nicht viele hilfreiche Informationen. Jede Hilfe wäre sehr sein geschätzt
import moment from 'moment';
export class Utils {
text: string;
constructor() {
console.log('Hello Utils Component');
}
//This function take the time in MS and the timezone and coverts it
//@params time - time in milliseconds
//@params tz - the timezone
//@paramz isZoneAbbr - true if the zone abbr should be displayed
//@return - return formattedTime
public formatTime(time, tz, isZoneAbbr): string {
console.log(JSON.stringify(moment));
return "";
// var formattedTime = moment.tz(time, tz);
// if (isZoneAbbr) {
// return formattedTime.format('h:mm a z');
// }
// return formattedTime.format('h:mm a');
};
}
ich meine Import-Anweisung, da beide 'Import versucht haben, * als Moment aus 'Moment'; '&' Moment aus 'Moment' importieren; ' – VirtualProdigy
brauchst du [angular2-moment] (https://github.com/urish/angular2-moment) auch –
@gerdi kein angular-moment ist nur Pipes meist. Sie sollten den tatsächlichen Moment in npm installieren, da Sie nur moment-timezones & types installiert haben – misha130