【发布时间】:2015-09-16 23:28:40
【问题描述】:
我正在尝试使用 ANGularJs+TypeScript 在页面加载时获取我的所有下拉列表。我已经完成了实现 ng-options 和 ng-init 方法来加载它,但我可能会遇到一些问题,这就是为什么我无法获得我的来自我的 API 的数据或调用我的 API。我已经用这个问题给出了我的代码。
这是我的打字稿控制器:-
/// <reference path="../interface/interface.ts" />
/// <reference path="../../scripts/typings/jquery/jquery.d.ts" />
/// <reference path="../../scripts/typings/angularjs/angular.d.ts" />
module CustomerNew.controllers {
export class CreateCustomerCtrl {
static $inject = ['$scope', '$http', '$templateCache'];
debugger;
constructor(protected $scope: ICustomerScope,
protected $http: ng.IHttpService,
protected $templateCache: ng.ITemplateCacheService) {
$scope.create = this.create;
$scope.getFormData = this.getformData;
}
public getformData: (getFormData: any) => {
$http.get();
}
给出错误 AS 它给出了“预期的属性或签名”和意外令牌的错误。 “需要构造函数、方法、访问器或属性”。
【问题讨论】:
-
你有什么错误?您只需将所有代码提供给我们,无需解释。很容易看出您的代码中有错误。例如:
$http.get('./Deskt...当你使用[HttpPut]时,不应该是$http.put吗?如果您想要一个好的答案,请解释您的问题。 -
@Antoine Esteve 我也更新了我的代码,是的,它给出了“预期属性或签名”和意外令牌的错误。 “需要构造函数、方法、访问器或属性”。 .
标签: angularjs angularjs-scope typescript typescript1.4 typescript1.5