我想和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中它可以正常工作。我究竟做错了什么?非常感谢你!

最佳答案

这种特殊情况在LightTable中是一个问题,应该用0.8.x修复。 In this thread是更多信息和示例项目。

10-06 00:17