Problems reloading model with new query param values

I am new to development and I’ve run into a real problem regarding query parameters and nested roues. I suspect I’m making a fundamental mistake somewhere and I’m hoping someone can help.

I have a form in my application that is supported by an action on the routes controller as follows:

  submitQuery() {
      switch (module) {
        case 'Opyion1':
           this.transitionToRoute('reports.newroutea', {
            queryParams: {
              dateFrom: this.get('dateFrom'),
              dateTo: this.get('dateTo'),
              unitNumber: this.get('unitNumber'),
              patientName: this.get('customerName'),
          },
      })

When the user clicks the submit button they are taken to the new route which loads a table underneath the form. This process works fine and produced a very nice table.

However I can only run the above process once. If I change the information in the inputs on the form and click the Submit button no changes are affected.

I assume this is because the route has already been loaded and it won’t reload unless there is a model change but this is where I run into all of my problems.

On the route that has been loaded the only way I can register the Query params is by putting something like

  queryParams: {
  dateFrom: { as: 'meddateFrom',
refreshModel:true},
  dateTo: { as: 'meddateTo', refreshModel:true},
  unitNumber: { as: 'medunitNumber', refreshModel:true},
  customerName: { as: 'medcustomerName', refreshModel:true},
},

in the route. If I don’t include the {as} then I receive an error about having duplicate Keys for params. If I don’t include them at all then the table doesn’t even load on the initial button press. It produces some really terrible behavior such as creating more params that are not needed.

I think I shouldn’t need to do this though because the params are passed as part of the transitionToRoute from the controller.

I have tried a number of different things but I think I am probably working from a bad starting point as nothing is working. Any help or advice is greatly appreciated.

I managed to get this sorted out. By taking the Query Params out of the controller and onto the Parent route, I was able to use the paramsFor in the sub route.

1 Like