简单" Hello World"在Angular2中给出了错误

时间:2016-12-29 11:22:26

标签: javascript angular components

制作第一个Angular2程序会产生一些错误。虽然,我觉得我写得正确。有人可以帮我吗?

<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.6/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/tools/system.js"></script>
    <script src="https://code.angularjs.org/tools/typescript.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.6/Rx.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.6/angular2.dev.js"></script>
    <script>
      System.config({
        transpiler: 'typescript',
        typescriptOptions: { emitDecoratorMetadata: true },
        packages: {'app': {defaultExtension: 'ts'}},
        map: { 'app': './angular2/src/app' }
      });

      System
          .import('hello_world_main')
          .then(null, console.error.bind(console));
    </script>
  </head>
<body>
   <my-app>Loading...</my-app>
</body>
</html>

hello_world_main.ts

import {bootstrap} from "angular2/platform/browser"
import {MyHelloWorldClass} from "hello_world_app.component"
bootstrap(MyHelloWorldClass);

hello_world_app.components.ts

import {Component, View} from "angular2/core";

@Component({
   selector: 'my-app'
})

@View({
  template: '<h2>Hello World !!</h2>'
})

export class MyHelloWorldClass {

}

文件位置:

enter image description here

错误:

enter image description here

0 个答案:

没有答案