我訪問變量時遇到問題,應該通過服務解決。如果我在html中直接使用這個變量是沒有問題的,但是當我想在方法中使用它時,我什麼也沒有。服務工作正常,它是http休息服務電話。 這裏的控制器:Typescript應該通過服務傳遞的角度訪問參數
,服務是這樣的:
/// <reference path='../_app.ts' />
module domain {
import DocumentEntity = domain.DocumentEntity;
export interface IDataAccessService {
getDataResource(): ng.resource.IResourceClass<IEntityResource>;
}
export interface IEntityResource extends ng.resource.IResource<domain.Entity> {
}
export class DataAccessService implements IDataAccessService {
//minification protection
static $inject = ["$resource"]
constructor(private $resource: ng.resource.IResourceService) {
console.log("DataAccessService Constructor");
}
getDataResource(): ng.resource.IResourceClass<IEntityResource> {
console.log("REST CALL");
return this.$resource("http://localhost:8080/services/name/:searchId/documents/", {searchId: "12345678"}, {
'query': {
method: 'GET',
isArray: false
}
});
}
}
angular.module("common.services", ["ngResource"]);
}
對不起,我在源代碼中有這個參數,但是在編輯這個帖子的實際URL時我刪除了它。我將編輯我的帖子。 – Ladislav
我仍然沒有看到它.. –