Angular和ASP.NET MVC的资源工厂

时间:2014-07-08 08:15:20

标签: asp.net asp.net-mvc angularjs asp.net-mvc-4 angular-resource

我正在从ASP.MVC页面http://host/Project/Index.cshtml调用资源到http://host/odata/ProjectAPI,依此类推。

Angular Factory可以正常使用前两个函数getProject和postProject,并将请求发送到http://host/odata/ProjectAPI(:projectId value)http://host/odata/ProjectAPI

但由于某些未知原因,getMembers和postMember方法正在向http://host/Project/..odata/ProjectAPI(:projectId)/Membershttp://host/Project/..odata/MemberAPI发送请求。 谁能解释一下? 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');

        }

    }


});

1 个答案:

答案 0 :(得分:0)

您的网址错误:

return $resource('..odata/ProjectAPI(:projectId)/Members'

return $resource('..odata/MemberAPI');

你已经......而不是../