Using queryParams in Controller init()


What’s the best way to make use of queryParams in a Controller’s init() function? When I try something like this:

export default Ember.Controller.extend({
  queryParams: ['paymentId', 'PayerID'],
  paymentId: null,
  PayerID: null,
  init: function() {
    var paymentId = this.get('paymentId');
    var payerId = this.get('PayerID');

When query parameters are specified in the URL, paymentId and payerId still return null in init(), I assume because it’s run before the queryParams are checked.

Why do I want to do this? To execute a PayPal payment after being redirected:


Controller initialization happens once, and when the object is created. Creation happens before the queryParams are attached to it. Any logic you’re trying to put here likely belongs in the route’s setupController.


@jasonmit, thanks - would specifying it in setupController() be the same effect as setting it in model()?


setupController is called once the model promise (if any) resolves