Skip to content
ts
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()

ts
qp(
   scope, 
   source, 
serviceProp): Record<string, RouteParamConfig>;

Defined in: src/reactive/query-param-route.ts:37

Parameters

scope

string

source

QPSource | QPSource[]

serviceProp

string = 'params'

Returns

Record<string, RouteParamConfig>


setupController()

ts
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:

app/routes/photos.js
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:

app/router.js
// ...

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

QPController

instance

model

unknown

Returns

void

Example

app/routes/post.js
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

ts
Route.setupController

Properties

_qpControllerParams

ts
_qpControllerParams: ControllerQueryParam[];

Defined in: src/reactive/query-param-route.ts:35


controllerName

ts
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 setupController method.
  • used as the controller for the template being rendered by the route.
  • returned from a call to controllerFor for the route.

Default

ts
null

Since

1.4.0

Overrides

ts
Route.controllerName

params

ts
params: QueryParamsService;

Defined in: src/reactive/query-param-route.ts:31


router

ts
router: RouterService;

Defined in: src/reactive/query-param-route.ts:32

Released under the MIT License.