How to use non-element controllers that get a model from a nested route

I have a simple application that returns a model from a child route.

export default Ember.Route.extend({
    model: function(params) {
        var store = this.get("store");
        return store.find("todo", params.todo_id);
    }
});

      

When my controller is singleton (default in ember today) it works fine. The model hook for the child routes is called and the model is bound to the controller / view / template as you would expect.

The trick is that when I flip the singleton bit my model suddenly disappears / undefined from the start. Today my initializer looks like this.

import Wat from "kanban/controllers/todos/todo";

export function initialize(container, application) {
    application.register('controller:todos/todo', Wat, {singleton: true });
}

      

If you change this value from true to false, the tests are aborted / the child route never gets a model for that controller.

Is this supported in ember 1.10+, and if so, what am I doing wrong here?

Here is a github thread for more context (this is a simple sample app to show if this is or is not supported - finding an ember-cli app is minimal)

https://github.com/toranb/kanban-board-without-ember-data/tree/nonSingletonSpike

Edit

Note: When using the ember inspector, I noticed that when the singleton was right (default), I see 3 controllers after the application has rendered. But when I flip it to false I only see 2 controllers ... making me think that the option "false" is no longer supported

However, when I add a function that listens for "init" in the controller itself, I see that it gets called and the controllerFor parameter value is displayed on the stack

controller = container.lookup('controller:' + name);

      

... is called from the inner elements of ember.

export default Ember.Controller.extend({
    x: function() {
        return true;
    }.on("init")
});

      

+3
ember.js


source to share


No one has answered this question yet

Check out similar questions:

8
How to access Ember model from route in Ember CLI
7
How to declare an element controller in an array controller - ember.js
4
Why is ember using the same controller instance on separate visits to the route?
1
Can the nested route ember.js use a different model and keep the controller context?
1
How to get Ember model data from controller correctly
0
Emberjs model gets lost in controller
0
Emberjs - model not updating based on dynamic segment in route
0
creating a controller prevents the model from getting a template
0
Ember: cannot get model in init function of controller
0
How do I enable page refresh when the Ember model loaded in the parent route has nested models passed to the child routes?



All Articles
Loading...
X
Show
Funny
Dev
Pics