Ich bin neu in der Angular2 World (und JS/TS). Bis jetzt habe ich alle Antworten auf meine Fragen im Web gefunden (hauptsächlich auf stackoverflow). Aber ich bekomme kein angular2-moment zur Arbeit.Verwenden Sie externe Typescript-Bibliothek in Angular2 (z. B. Angular2-Moment)
Ich folge tat den Anweisungen auf The angular2-Moment GitHub-Page, aber ich erhalte den folgenden Fehler in dem Moment meine app Lasten:
angular2-polyfills.js:127 GET http://localhost:8080/angular2-moment 404 (Not Found)
http://localhost:8080/angular2-moment(…)
Webstrom hat der Import als: import {DateFormatPipe} from "angular2-moment/index";
Ich habe versucht, dies zu ändern: import {DateFormatPipe} from "angular2-moment";
, import {DateFormatPipe} from "angular2-moment/DateFormatPipe";
oder import {DateFormatPipe} from "angular2-moment/DateFormatPipe.js";
aber das hilft nicht.
Wenn ich den Import import {DateFormatPipe} from "node_modules/angular2-moment/DateFormatPipe.js";
ich die folgende Fehlermeldung erhalten, ändern:
GET http://localhost:8080/moment 404 (Not Found)
http://localhost:8080/moment(…)
Ich weiß nicht, was ich falsch mache, könnte etwas Hilfe hier verwenden. Vielen dank für Deine Hilfe!
Ich benutze die angular2-rc und wollen es so verwenden:
@Component({
selector: ...,
template: ...,
pipes: [DateFormatPipe]
})
EDIT: Dank @Sasxa konnte ich mein Problem lösen. Aber ich musste es noch ein wenig herausfinden, also werde ich meine genaue Lösung veröffentlichen. Ich änderte meine system.config.js
zu:
....
var map = {
'app': 'build/app', // 'dist',
'@angular': 'node_modules/@angular',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'rxjs': 'node_modules/rxjs',
'moment': 'node_modules/moment/moment.js', //<--this
'angular2-moment': 'node_modules/angular2-moment' //<--this
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'main.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'angular2-moment': { defaultExtension: 'js' }//<--this
};
...
Btw: das Recht, den Import als import {DateFormatPipe} from "angular2-moment/index";
tatsächlich funktioniert.