无法解决这个问题,我不确定它为什么要来。
boot.ts
"use strict";
import {bootstrap} from '../angular2/platform/browser';
import {appComponent} from '../components/app/appComponent';
bootstrap(appComponent);
appComponent.ts
'use strict'
import {Component} from '../../angular2/core';
@Component({
selector: 'app',
templateUrl: 'components/app/app.html'
})
export class appComponent {
message:string='Hello html';
}
并在HTML文件中
<script>
System.config({
defaultJSExtensions: true,
packages: {
app: {
defaultExtension: 'js'
}
}
});
System.import('components/boot').then(null, console.error.bind(console));
</script>
答案 0 :(得分:0)
我看到你使用angular2模块的相对路径。也许你可以尝试这样的事情:
'use strict'; // <------------
import {bootstrap} from 'angular2/platform/browser';
import {appComponent} from '../components/app/appComponent';
bootstrap(appComponent);
和
'use strict';
import {Component} from 'angular2/core'; // <------------
@Component({
selector: 'app',
templateUrl: 'components/app/app.html'
})
export class appComponent {
message:string='Hello html';
}
您需要将Angular2 dist这样包含在您的HTML文件中:
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
(...)
希望它可以帮到你, 亨利