Ich bin ein Neuling zu Typescript und Angular2.Ich habe einen app
Ordner, wo ich ts Dateien erstellen und ich versuche, transpiled 'js' Dateien in einen anderen Ordner erstellt. 'Js' Dateien werden erfolgreich erzeugt, aber wenn ich versuche, die Dateien in HTML import
mit System.import('built')
zu verwenden, werden Skripte nicht referenziert und werfen 404
. Die Ordner "app" und "built" werden zum Stamm hinzugefügt. Hier ist meine tsconfig.json:System.Import in Typescript nicht überschreiben den Standardpfad
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "built"
}
}
Und hier habe ich die Skripte index.html bin importieren:
System.import('built').catch(function(err){ console.error(err); });
Jede Hilfe.
Edit: Hier habe ich hinzugefügt die systemjs.config.js:
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
}
}
});
})(this);
ich es gerade getestet mit quickstart-app und in meinem Fall funktioniert es, wenn ich 'System.import ('built') mache. catch (function (err) {console.error (err);});' Kannst du mir deine 'systemjs.config zeigen? .js'? – micronyks
@micronyks hat die Frage mit systmjs.config.js aktualisiert – Vivek