【发布时间】:2016-04-06 07:48:24
【问题描述】:
我有这个打字稿,我想编写 ES6 等价物。我正在学习 Angular 2,并且更喜欢使用 ES6 而不是 typescript,并且所有示例都在 ES5 或 typescript 中。如果我看到这段代码是如何用 ES6 编写的,那么我应该能够从那里使用我需要基于 typescript 编写的任何新代码来获取它。干杯。
'use strict';
import {Component, bootstrap} from 'angular2/angular2';
// Annotation section
@Component({
selector: 'my-app',
template: '<h1>Hello {{ name }}</h1>'
})
// Component controller
class MyApp {
constructor() {
this.name = 'Max';
}
}
【问题讨论】:
-
对于所有来这里了解如何将 Angular2 打字稿转换为 JavaScript 的人,这里有一个来自 Angular2 食谱的方便指南:angular.io/docs/ts/latest/cookbook/ts-to-js.html。请注意,示例是 TS 到 ES5。
标签: javascript typescript ecmascript-6 angular