简体   繁体   中英

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.

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.

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
Could anyone explain? PS: this requests are sent from same page but different tabs

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 ../

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM