ember.js - Dynamic API namespace change -
i've got application needs change api namespace dependent on state. illustrate point, here api endpoints:
/groups (lists groups) /foo/users (lists users in group foo) /bar/users (lists users in group bar)
i navigate foo
route, click on users link. how can change namespace users dynamically?
update here code. i'm still figuring ember out, , js knowledge bit shaky.
i use ember-data restadapter i've subclassed. importantly have this:
app.restadapter.reopen({ url: "http://127.0.0.1:5001" });
this works quite well, thought of putting following controller
app.grouproute = em.route.extend({ setupcontroller: function(controller) { app.restadapter.reopen({url:"http://127.0.0.1:5000", namespace: 'blah'}); controller.set('model', app.user.find()); } });
but makes no difference. understanding makes sense change namespace when controller initialized (since @ stage know namespace should be), not sure how make happen
update 2
i've managed work following code. best way of doing it?
var id = window.app.__container__.lookup('controller:group').get('id'); app.restadapter.prototype.namespace = id;``
Comments
Post a Comment