为什么世界你好文本不显示?

问题描述 投票:1回答:2

我在角2。我的新看到这个视频https://egghead.io/lessons/angular-2-say-hello-world-to-angular-2

现在,我想就plunker我想这样的演示一样

http://plnkr.co/edit/uQa9ZIvb38iTMaXsecaC?p=preview

请告诉我在哪里做错了

//代码放在这里

import {bootstrap} from 'angular';
import {Component} from 'angular2/core';


@Component({
  selector:'app',
  template:'<div>hello</div>'

})

class App{}


bootstrap(App)
angular angular2-template
2个回答
1
投票

Here a working plunker

事情,你应该牢记:

  • 当您使用System.import('file.ts'),你不需要<script src="file.ts">
  • 确保你System.config transpiler: 'typescript'

希望这可以帮助。


1
投票

添加到您的HTML代码。这里是官方example

<script>
  System.config({
    transpiler: 'typescript', 
    typescriptOptions: { emitDecoratorMetadata: true }, 
    packages: {'app': {defaultExtension: 'ts'}} 
  });
  System.import('app/boot')
        .then(null, console.error.bind(console));
</script>

编辑

你会发现在这里工作示例plunker

编辑

更新plunker。你也必须把在独立的文件夹的包文件。

© www.soinside.com 2019 - 2024. All rights reserved.