我在角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)
事情,你应该牢记:
System.import('file.ts')
,你不需要<script src="file.ts">
System.config
transpiler: 'typescript'
希望这可以帮助。
添加到您的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。你也必须把在独立的文件夹的包文件。