1

(This question is a continuation of this one)

I need to specify the API endpoints on a model by model basis. How can I do this? The closest I have come to this is the description of namespace, but this applies to the top-level URL.

My problem is that my API structure is not the one that emberjs expects. For example, I have this two objects, with completely different API endpoints:

phones -> /api/nodes/extensions/phones
nodes  -> /api/nodes

How can I configure the endpoints for each model?

4

1 回答 1

2

如果我没记错的话,你应该可以设置Modelurl 属性,如下所示:

App.Phone = DS.Model.extend({
    description: DS.attr('string'),
    number: DS.attr('string')
}).reopenClass({
    url: 'api/nodes/extensions/phones'
});

App.Node= DS.Model.extend({
    description: DS.attr('string')
}).reopenClass({
    url: 'api/nodes'
});

我没有在第 12 版中尝试过这个,所以我不能保证它有效。

或者,您可能想查看这个问题和答案,它讨论了类似的场景,但对修订版 11 中引入的特定模型使用适配器。

于 2013-04-05T14:45:21.937 回答