1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30import Route from '@ember/routing/route';
import { service } from '@ember/service';
export default class SearchRoute extends Route {
@service header;
queryParams = {
all_keywords: { refreshModel: true },
page: { refreshModel: true },
q: { refreshModel: true },
sort: { refreshModel: true },
};
model(params) {
// we need a model() implementation that changes, otherwise the setupController() hook
// is not called and we won't reload the results if a new query string is used
return params;
}
setupController(controller, params) {
this.header.searchValue = params.q;
controller.fetchData();
}
deactivate() {
super.deactivate(...arguments);
this.header.searchValue = null;
}
}