我想玩 Angular2 - 一个非常简单的开始!我只是将一些代码从 angular.io 复制到我的文件中。在 LightTable(集成浏览器)中,此代码不起作用:
<!DOCTYPE html>
<html>
<head>
<title>Angular2 TestApp</title>
<script type="text/javascript" src="./libs/angular2.sfx.dev.js"></script>
<script type="text/javascript" src="./src/main.js"></script>
</head>
<body>
<my-app></my-app>
</body>
</html>
main.js 的 JavaScript:
function AppComponent() {}
AppComponent.annotations = [
new angular.ComponentAnnotation({
selector: 'my-app'
}),
new angular.ViewAnnotation({
template: '<h1>My first Angular 2 App</h1>'
})
];
document.addEventListener('DOMContentLoaded', function() {
document.body.innerHTML += 'Hi'; //for checking, whether the file is recognized
angular.bootstrap(AppComponent);
});
现在在 LightTable(浏览器)中,我收到以下错误消息:
Uncaught Error: ModuleEvaluationError: undefined is not a function in traceur-runtime@0.0.88/src/runtime/async.js
angular2.sfx.dev.js [2331] UncoatedModuleInstantiator.getUncoatedModule
angular2.sfx.dev.js [2413] ModuleStore.get
angular2.sfx.dev.js [3187] anonymous
Uncaught ReferenceError: angular is not defined
main.js [5] anonymous
但在当前的 Firefox 中,它运行良好。我究竟做错了什么?非常感谢你!