1

Trying to figure out how to have a completely optional parameter for a state so that having a query string on the URL of what otherwise would be the home state(/) will actually route to the search state. Not sure if Regex here is even the proper approach.

URL -> State mapping

  • url / should go to state home
  • url /?search= should go to state search
  • url /?search=foo should go to state search
  • url /:slug/ should go to state search
  • url /:slug/?search=foo should go to state search

Home State

name: 'home',
url: '/',
component: 'appHome',

Search State

name: 'search',
url: '/{slug: [.*]?}?search=',
component: 'appCategory',
params: {
    slug: { dynamic: true },
    search: { dynamic: true },
},
tekstrand
  • 1,473
  • 1
  • 10
  • 22

0 Answers0