角度资源覆盖网址无法正常工作

bin*_*680 7 resources angularjs

这里的文档说:

url – {string} – action specific url override. 
The url templating is supported just like for the resource-level urls.
Run Code Online (Sandbox Code Playgroud)

我想用这个好功能,我试过这个:

angular.module("experience", ['ngResource'])

    .factory('Experience', function ($resource, identity) {

    return $resource("api/experiences/:id", {}, {
        queryAll : {
            method  : 'GET',
            url     : 'api/companies/' + identity.id + '/experiences',
            isArray : true
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

您看到我正在尝试覆盖queryAll方法的网址.但这不起作用,查询仍然发送url api/experience.这是真的支持还是我做错了什么?谢谢你的帮助.

Eth*_* Wu 2

我的项目中有一个非常相似的问题。无法在资源操作中覆盖该 url。我正在使用 Angular 1.2.0,它应该从 1.1.4 开始支持该功能。所以我检查了 Angular API 参考 CHANGELOG,但没有运气。然后我深入研究了源代码,发现重写 url 的逻辑不存在。这就是问题的根本原因。我将Angular更新到1.2.0,但是忘记更新angular-resource.js到相应的版本。

所以,长话短说:检查 angular-resource.js 的版本