[英]Resource Factory of Angular and ASP.NET MVC
I am calling resources from a ASP.MVC page http://host/Project/Index.cshtml
to http://host/odata/ProjectAPI
and so on. 我正在从ASP.MVC页面http://host/Project/Index.cshtml
调用资源到http://host/odata/ProjectAPI
,依此类推。
Angular Factory works fine with first two functions getProject and postProject and send request to http://host/odata/ProjectAPI(:projectId value)
and http://host/odata/ProjectAPI
consequently. Angular Factory的前两个功能getProject和postProject可以正常工作,然后将请求发送到http://host/odata/ProjectAPI(:projectId value)
和http://host/odata/ProjectAPI
。
But for some unknown reasons getMembers and postMember methods are sending request to http://host/Project/..odata/ProjectAPI(:projectId)/Members
and http://host/Project/..odata/MemberAPI
但是出于某些未知原因,getMembers和postMember方法将请求发送到http://host/Project/..odata/ProjectAPI(:projectId)/Members
和http://host/Project/..odata/MemberAPI
Could anyone explain? 谁能解释? PS: this requests are sent from same page but different tabs PS:此请求是从同一页面发送的,但标签不同
app.factory('resourceProject', function ($resource) {
return {
getProject: function () {
return $resource('../odata/ProjectAPI(:projectId)', { projectId: '@id' });
},
postProject: function () {
return $resource('../odata/ProjectAPI');
},
getMembers: function () {
return $resource('..odata/ProjectAPI(:projectId)/Members', { projectId: '@id' });
},
postMember: function () {
return $resource('..odata/MemberAPI');
}
}
});
Your URL's are wrong: 您的网址有误:
return $resource('..odata/ProjectAPI(:projectId)/Members'
return $resource('..odata/MemberAPI');
You've put .. instead of ../ 您放了..而不是../
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.