1

I'm using ui-router project to handle my web-app navigations. In my screens I have input widgets (like date-picker and selectors) which change the query parameters in the url. In order to do so I declare the state as follows:

angular.module('my.project', ['ui.router', 'ngMaterial'])
  .config(['$stateProvider', function ($stateProvider) {
      $stateProvider
          .state('page', {
             url: '/page?customerid%from%to',
             // rest of state definition
      })});

Then, when things change on screen, I use $state.go(). For example, if the from widget changes I call $state.go('.', {from: fromwidget.text}) which changes the url.

Thing is, I have a lot of parameters that can change and I feel it's a bit redundant to define each of these params in the url section of the state definition. I would like to just declare the base-url, in my case url: '/page' and when I call $state.go() to change the $stateParams and just use them in my controller. I don't have any need to know in advance the exact parameters that are allowed to be passed to the state

Avi
  • 21,182
  • 26
  • 82
  • 121
  • Not really sure if you can do that with $stateParams, maybe just define the state with the base path and use $location to get the parameters ? – Walfrat May 09 '16 at 14:07
  • @Walfrat - Thanks for your comment. Thing it, if I don't define the parameters in the state, I can't use `$state.go()` to change the url. And I do want to use this, just don't want to define the params in advance :) – Avi May 09 '16 at 14:10
  • you may find this answer helpful: http://stackoverflow.com/a/26021346/2460773 – Nitsan Baleli May 11 '16 at 08:09

0 Answers0