How can I get the rootURL in App.Router in my controller to use in my JSON request?
If I specify a rootURL like this:
App.Router.reopen({
rootURL: '/site1/'
});
I want to be able to do something like this:
FooController = Ember.ObjectController.extend({
needs: ["application"],
actions: {
examine: function() {
var rootURL = this.get('controllers.application.router.rootURL');
$.getJSON(rootURL + "/examine/" + id).then(function(response) {
// do stuff with response
});
}
}
});
The router is injected onto all routes, you can move that action up to the route and grab the router off of that.
Or you can just add the property to the controller when the route is setting up the controller.
Example: http://emberjs.jsbin.com/tomuhe/1/edit