![](/img/trans.png)
[英]Typescript: render custom script tag throws error TS1005: '}' expected
[英]grunt causing error TS1005: ';' expected
我正在使用angular和Typescript访问REST Web服务。 我对打字稿很陌生,所以我的问题可能很基本,或者我的方法是错误的。 我一直收到错误TS1005: ';' expected
当grunt编译我的exampleController.ts时,可以TS1005: ';' expected
。 我已经搜索了解决方案,但没有找到任何可以帮助我的东西。 我已经在使用import angular = require('angular');
我的控制器代码如下所示:
class ExampleComponentController {
public static $inject = [
'$scope',
'productRestService',
'$http'
];
$scope.submit = function(form) {
var config = {
'username' : $scope.name,
'password' : $scope.pass
};
var $promise = $http.post('requat_url', config)
.success(function(data, status, headers, config) {
...
})
.error(function(data, status, headers, config) {
...
});
};
constructor(...) {...}
}
错误出现在$scope.submit
所在的行。 任何建议都适用。
代码$scope.submit...
必须在构造函数中。 构造函数的参数必须与$inject
列表匹配:
class ExampleComponentController {
public static $inject = [
'$scope',
'productRestService',
'$http'
];
constructor($scope, productRestService, $http) {
$scope.submit = function (form) {
var config = {
'username': $scope.name,
'password': $scope.pass
};
var $promise = $http.post('requat_url', config)
.success(function (data, status, headers, config) {
})
.error(function (data, status, headers, config) {
});
};
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.