I have a search page where we are getting different types of search results. In the list of search results I would like to use
{{#linkTo \'someResources.someRes
Ember will bypass the model()
hook when using linkTo
as you've discovered. The assumption is that you passed a model to it, so it and will use that(result
) as the model
.
The next hook you can use is setupController
. Since you have a model
hook that works on the direct route, you can use call it directly from here.
One caveat is that you need to also allow for the direct route loading where the model will already have loaded.
setupController: function(controller, model) {
if (!model.isModel) {
this.model().then(function(result)) {
controller.set('model', result)
}
}
}
model.isModel
is this check via an isModel property on the directly loaded model, which should be absent when passed with linkTo
.
Note: the above code assumes that you are returning a Promise
in your model()
hook.