Problem with query params with async controllers

I have been using async controllers that conclude in the aftermodel of a route.

The problem is the hooks for query params end up a little screwed up. I tried shifting this to the beforeModel in an attempt to get the hooks working, but unfortunately while the initial null states update the URL, it comes in with params declared in the url doesn’t bind the properties to url and vice versa from the controller. Is there a call to rebind the query params after I load in my controller for the applicable route? example: JS Bin

1 Like

I wasn’t sure why you’re returning a controller in your route. If I’m missing a use case let me know, but here is what I think you were trying to achieve.

Also, sortBy is actually a function and one you probably don’t want to override.

I want to return a controller in the route so that I don’t have to load the controllers at the beginning of the application but only when it needs to. The problem is the queryParams don’t connect to the controller later, or at least it doesn’t seem to be able to.

I want to return a controller in the route so that I don’t have to load the controllers at the beginning of the application but only when it needs to.

I’m not sure there is any advantage here, especially in the case of the Application controller. Are you sure this isn’t a premature optimization?

You’re doing something unconventional, so I’m not surprised there would be issues with it.

Also, when you define your controller with extend, it’s not instantiating it. The router is responsible for this in a generateController method. Are you trying to lazily load the controller AMD style? That could be your use case just not explained up front in the issue.

yes in my bigger project I am using require to lazy load the controller. My application controller isn’t actually being lazy loaded but all the other routes are being lazy loaded. I then register it via this.container.register

It definitely seem like an issue that will come up as Ember brings first class support for lazy loading.

I would recommend filing a bug: Issues · emberjs/ember.js · GitHub.

Edit: it seems like this is already being discussed here https://github.com/emberjs/ember.js/issues/5672