import { QPRoute } from '@trail-run/core/reactive/query-param-route';Class: QPRoute
Defined in: src/reactive/query-param-route.ts:30
Extends
Route
Methods
qp()
qp(
scope,
source,
serviceProp): Record<string, RouteParamConfig>;Defined in: src/reactive/query-param-route.ts:37
Parameters
scope
string
source
serviceProp
string = 'params'
Returns
Record<string, RouteParamConfig>
setupController()
setupController(controller, model): void;Defined in: src/reactive/query-param-route.ts:103
A hook you can use to setup the controller for the current route.
This method is called with the controller for the current route and the model supplied by the model hook.
By default, the setupController hook sets the model property of the controller to the specified model when it is not undefined.
If you implement the setupController hook in your Route, it will prevent this default behavior. If you want to preserve that behavior when implementing your setupController function, make sure to call super:
import Route from '@ember/routing/route';
import { service } from '@ember/service';
export default class PhotosRoute extends Route {
@service store;
model() {
return this.store.findAll('photo');
}
setupController(controller, model) {
super.setupController(controller, model);
this.controllerFor('application').set('showingPhotos', true);
}
}The provided controller will be one resolved based on the name of this route.
If no explicit controller is defined, Ember will automatically create one.
As an example, consider the router:
// ...
Router.map(function() {
this.route('post', { path: '/posts/:post_id' });
});
export default Router;If you have defined a file for the post controller, the framework will use it. If it is not defined, a basic Controller instance would be used.
Parameters
controller
instance
model
unknown
Returns
void
Example
import Route from '@ember/routing/route';
export default class PostRoute extends Route {
setupController(controller, model) {
controller.set('model', model);
}
});Method
setupController
Since
1.0.0
Overrides
Route.setupControllerProperties
_qpControllerParams
_qpControllerParams: ControllerQueryParam[];Defined in: src/reactive/query-param-route.ts:35
controllerName
controllerName: string = '-qp';Defined in: src/reactive/query-param-route.ts:34
The name of the controller to associate with this route.
By default, Ember will lookup a route's controller that matches the name of the route (i.e. posts.new). However, if you would like to define a specific controller to use, you can do so using this property.
This is useful in many ways, as the controller specified will be:
- passed to the
setupControllermethod. - used as the controller for the template being rendered by the route.
- returned from a call to
controllerForfor the route.
Default
nullSince
1.4.0
Overrides
Route.controllerNameparams
params: QueryParamsService;Defined in: src/reactive/query-param-route.ts:31
router
router: RouterService;Defined in: src/reactive/query-param-route.ts:32