0

I want to search on my page. Actually, my code is

$stateProvider
  .state('aaa', {
    url: '/aaa',
    templateUrl: 'client/parties/views/aaa.ng.html',
    controller: 'Aaa'
  })

$urlRouterProvider.otherwise("/default");

And now, I want to search on my page, but the params MUST working with the URL. How to use params when I have $urlRouterProvider.otherwise? Actually, everything after /aaa/ in URL causes redirect to /default.

Important thing: I have more than 20 parameters, but when there're not selected, I don't want to pass it via URL. This is important because I think I can't do something like url: '/details/:param1:param2:param3:param4',

Can you help me?

1 Answer 1

1

Looking at the documentation for ui-router, it doesn't seem like it is possible to not have it redirect without having at least one parameter defined on the state's route.

To accomplish what you want, I think the best is to use a catch all parameter of some sort. It's either that, restricting deep-linking, or reducing the amount of parameters and manually defining it.

  1. Define a catch all parameter as shown below. In this case the parameter is path redirects will not take place if there is nothing after "/files/":

    '/files/{path:.*}' - Matches any URL starting with '/files/' and captures the rest of the path into the parameter 'path'.
    '/files/*path' - Ditto. Special syntax for catch all.

  2. Define one parameter on a new route, and then split the one parameter into multiple parameters in the controller.
Sign up to request clarification or add additional context in comments.

2 Comments

I'm trying now with passing all the parameters in one parameter in .state, but I have an issue. When I want to go to my state: $state.transitionTo('partiesWithParams', {searchParams:'lol'}, { reload: false, inherit: false, notify: true }); whole the page is reloading. How to prevent it?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.