我需要 Ember 在调用 REST 端点时停止尝试猜测,但找不到这样做的方法。
如果我有一个端点,/services
,我希望 ember 总是打电话/services
不管我是否打电话给find('services')
or find('services', 1)
对于单数也一样。
是否可以禁用此行为?即使我必须重写 REStAdapter 中的方法也可以。
Thanks!
当然可以,但您仍然应该使用 find('service')。
复数(这是默认实现)
App.ServiceAdapter = DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return Ember.String.pluralize(camelized);
},
});
Singular
App.ServiceAdapter = DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return camelized; //Ember.String.pluralize(camelized);
},
});
基单类
App.BaseSingularAdapter = DS.RESTAdapter.extend({
pathForType: function(type) {
var camelized = Ember.String.camelize(type);
return camelized; //Ember.String.pluralize(camelized);
},
});
使用下面的代码,Foo 和 Bar 都是单数
App.FooAdapter = App.BaseSingularAdapter;
App.BarAdapter = App.BaseSingularAdapter;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)