【发布时间】:2014-09-02 06:44:13
【问题描述】:
我刚刚开始使用 TypEcs,我正在尝试在 Typescript 和 AngularJS 中创建一个网页,我想在 Eclipse 中进行调试。
- 是否可以在 Eclipse 中调试 TypeScript 和 Angular 页面?如果是这样,那么您能指导我正确的方向吗?
我尝试使用 TypeScript Standalone 选项调试单个打字稿文件,它可以工作。但我也想使用 AngularJS。我创建了一个 index.html 文件和一个 app.ts 文件,我还将 angular.d.ts 和 angular.min.js 等导入到脚本文件夹中。 我可以通过使用任何 TypEcs TypeScript 调试器来做到这一点吗?我尝试运行它,但在 var app = angular.module... 出现错误(ReferenceError: angular is not defined)。
我的猜测是我在索引文件中链接到的 angular.min.js 文件尚未加载。是因为 app.ts 设置为 TypeScript Standalone 配置中的主文件吗? (我无法选择 index.html)和/或我是否缺少一些代码/设置?
我希望你能帮助我。 提前谢谢!
下面是一些示例代码: index.html:
<html ng-app="helloworld">
<head>
<title>Hello World!</title>
</head>
<body>
<div class="container" ng-controller="HelloWorldCtrl">
<input type="text" class="form-control" value="{{message}}" />
</div>
<script src="../scripts/angular.min.js"></script>
<script src="app.js"></script>
</body>
</html>
app.ts:
/// <reference path="../scripts/typings/angularjs/angular.d.ts"/>
module Sample.HelloWorld {
export interface IHelloWorldScope extends ng.IScope {
message: string;
}
export class HelloWorldCtrl {
static $inject = ["$scope"];
constructor(private scope: IHelloWorldScope) {
scope.message = "Hello World";
}
}
var app = angular.module("helloworld",["ui.bootstrap"]);
app.controller("HelloWorldCtrl", HelloWorldCtrl);
}
【问题讨论】:
-
您可以使用来自github.com/eclipse/wildwebdeveloper 的Eclipse Wild Web Developer,它内置了对TypeScript 调试的支持。
标签: eclipse angularjs typescript