【发布时间】:2016-03-26 03:25:00
【问题描述】:
我的 bundle out.js 文件连接了一个 main.js 和一个 app.component.js 模块。现在我想用 SystemJS 在我的 index.html 中导入这个 out.js 文件。其实我想在里面“调用”main(.js)-module。
我现在想知道如何导入我的捆绑文件的内部模块。将 System.import (内部模块)嵌套在外部 System.import (捆绑)中是否正确?实际上它正在工作,但我不确定这是否可以。
index.html
<script type="text/javascript" src="lib/out.js"></script>
<script>
System.config({
packages: {
lib: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('lib/out')
.then(function() { // ---Is this the way to do it?---
System.import('/main');
}, console.error.bind(console));
</script>
out.js
System.register('app.component', ['angular2/core'], function(exports_1, context_1) {
var __moduleName = context_1 && context_1.id;
..
}};
System.register('main', ['angular2/platform/browser', './app.component'], function(exports_1, context_1) {
var __moduleName = context_1 && context_1.id;
..
}};
【问题讨论】:
标签: javascript angular systemjs