以下是从 angularjs 2 es6 模板http://goo.gl/IGaTZw开始的 plunker 我添加了 traceur 并删除了 main.es6.js 替换为 main.js 以防隐式模式受到干扰。
<head>
<script data-require="traceur-runtime@0.0.88" data-semver="0.0.88" src="https://cdn.rawgit.com/google/traceur-compiler/d3d0553de3315398a956dc2f9edd6a982d786b0a/bin/traceur-runtime.js"></script>
<script src="https://jspm.io/system.js"></script>
<script src="https://code.angularjs.org/2.0.0-alpha.30/angular2.dev.js"></script>
</head>
<body>
<app></app>
<script>System.import('main');</script>
</body>
Main.js-----
import {
ComponentAnnotation as Component,
ViewAnnotation as View, bootstrap
} from 'angular2/angular2';
@Component({
selector: 'app',
viewInjector: [Service]
})
@View({
template: '{{greeting}} world!'
})
class App {
constructor(service: Service) {
this.greeting = service.greeting();
setTimeout(() => this.greeting = 'Howdy,', 1000);
}
}
class Service {
greeting() {
return 'Hello';
}
}
bootstrap(App);
我尝试在本地下载脚本文件,但在那里也失败了。我不能使用 npm 等,因为我的笔记本电脑有问题。
提前谢谢了。