AngularJS$资源假调用
我真的需要帮助假装打ngResource电话。AngularJS$资源假调用,angularjs,http,resources,ngresource,Angularjs,Http,Resources,Ngresource,我真的需要帮助假装打ngResource电话。 我的意思是: public getResource(fake: boolean) { return this.$resource("/my-url/:param", { param: "@param" }, { get: this.getConfig(fake), }, ); } private getConfig(fake: boolean) { return fake ? t
我的意思是:
public getResource(fake: boolean) {
return this.$resource("/my-url/:param",
{
param: "@param"
},
{
get: this.getConfig(fake),
},
);
}
private getConfig(fake: boolean) {
return fake ? this.mockResponse() : { method: "GET", isArray: false };
}
private this.mockResponse() {
return {
method: "GET",
url: "",
interceptor: {
response: () => {
return { key: "value" },
}
},
};
}
所以,这段代码返回所需的对象,但它也进行调用。我需要它在没有任何调用的情况下返回模拟对象。谢谢大家! 我不确定这是否相关,但你在“拦截器”@maaw no:)中有一个输入错误。我只是键入了它,没有复制。目的是给出想法,我拥有什么,我需要什么