1

I'm using Angular ui route and I'm trying to pass query parameters but it doesn't work. I have followed the official wiki.

In the view I have the following code very simple

<div ng-controller="MainController">
  <a ng-href="#/foo/bar?param={{make}}"><li>{{make}}</li></a>
</div>

and this is the config

function config($stateProvider, $urlRouterProvider) {
    $stateProvider
      .state('foo', {
        url: '/foo',
        templateUrl: '/partials/foo.html',
        controller: 'MainController'
      })
      .state('foo.bar', {
        url: '/bar?param',
        templateUrl: 'partials/foo.bar.html',
        controller: 'SecondaryController'
      });
  }

but when I click on the link in the view the url I get it is what I get but the route doesn't receive the request.

1 Answer 1

4

Use ui-sref directive to generate href link

Markup

<div ng-controller="MainController">
  <a ui-sref="foo.bar({param: make})"><li>{{make}}</li></a>
</div>
Sign up to request clarification or add additional context in comments.

14 Comments

Already done that as suggested to this post stackoverflow.com/questions/25569346/…
Unfortunately the make contains some spaces and I got errors
@Mazzy what do you mean by make contains some space?
make could be for example `The Facebook'. As you might see there are space
@Mazzy you should look at this stackoverflow.com/questions/28639852/… where I solved the problem what you are getting
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.