我原来的代码看起来像这样(见下文)。注意$ inject语句。
module app.common {
interface IProductResource
extends ng.resource.IResource<app.domain.IProduct> {
}
export class ResourceFactory {
static $inject =["$resource"];
constructor(private $resource: ng.resource.IResourceService) {
}
public getProductResource() : ng.resource.IResourceClass<IProductResource> {
return this.$resource("/api/products/:productId");
}
}
factory.$inject = ["$resource"];
function factory($resource) : ResourceFactory {
return new ResourceFactory($resource);
}
angular
.module("common.services")
.factory("resourceFactory",
["$resource",
factory]);
}
我的新代码利用了lambda语法,看起来像这样(见下文)。在这种情况下如何处理缩小问题?
module app.common {
interface IProductResource
extends ng.resource.IResource<app.domain.IProduct> {
}
export class ResourceFactory {
static $inject =["$resource"];
constructor(private $resource: ng.resource.IResourceService) {
}
public getProductResource() : ng.resource.IResourceClass<IProductResource> {
return this.$resource("/api/products/:productId");
}
}
angular
.module("common.services")
.factory("resourceFactory",
["$resource",
($resource)=>new ResourceFactory($resource)]);
}