我正在尝试设置Hello,AngularJS 2应用程序,这是第一次。
下面是简单的HTML:
<!doctype html>
<html>
<body>
<my-app></my-app>
<script type="application/dart" src="hello.dart"></script>
<script src="packages/browser/dart.js"></script>
</body>
</html>和飞镖代码:
class Hello{
String message;
Hello(){
HttpRequest.getString('/hello')
.then((String content) {
Map parsedMap = JSON.decode(content);
message = parsedMap["Message"];
});
}
}
main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap(AppComponent);
}有人能帮我把这个Dart代码转换成TypeScript吗?
发布于 2016-07-05 22:00:16
有人能帮我把这个Dart代码转换成TypeScript吗?
提示:
main。applicaiton/json类型的http响应通常会自动解析(对象化)。在此基础上:
import {bootstrap} from "some/angular/module";
// Do same for http
class Hello {
message: string;
hello() {
http.getString('/hello')
.then((content) {
const message = content;
});
}
}
bootstrap(AppComponent);更多
我强烈建议你读一本关于TypeScript的书。我写了一个免费的:https://basarat.gitbooks.io/typescript/content/docs/getting-started.html
发布于 2019-01-20 09:48:35
Dart2Ts是一种高度实验性的类型转换编译器。
https://stackoverflow.com/questions/38213403
复制相似问题