0

I have a state as following :

.state('app.jobsList', {
  url : '/jobs-list?typeContrat&ville&competence',
  controller : 'OffresController',
  templateUrl : 'views/tmpl/jobs.html'
})

to call this state I can use the following links :

app/jobs-list?typeContrat=
app/jobs-list?ville=
app/jobs-list

In my navbar I have an attribute to call app/jobs-list as following :

<a ui-sref="app.jobsList">Offres</a>

When I click on the link it works and it redirects me to that state.

And in my footer I have other attributes that calls these links :

app/jobs-list?typeContrat=
app/jobs-list?ville=

When I click on them they work and they redirects me to the app.jobsList state with the query string.

The problem is when I call one of these urls, and then I click on the attribute which has to redirect me to the app/jobs-list it doesn't work and it stays on the app/jobs-list?typeContrat= or app/jobs-list?ville=.

How can I solve this ?

Edit:

This is how I redirect in my footer :

<a href="" ng-click="search(null,ville.nomVille,null)">{{ville.nomVille}}</a></li>

And this is the search function:

$scope.search = function(typeContrat, ville, competence){
      $state.go('app.jobsList',{typeContrat:typeContrat,ville:ville,competence:competence});
    };
2
  • Can you show how are you redirecting to app/jobs-list?typeContrat= and app/jobs-list?ville= in your footer? Commented Jul 12, 2016 at 15:36
  • @Chinni please check my edit Commented Jul 12, 2016 at 15:42

1 Answer 1

2

You're trying to reload the same state with new params. to force state reload use

<a ui-sref="app.jobsList({param1: 1, param2: 2})" data-ui-sref-opts="{reload: true}">Some text</a>

Or with $state:

$state.go('app.jobsList',{typeContrat:typeContrat,ville:ville,competence:competence}, {reload: true});
Sign up to request clarification or add additional context in comments.

2 Comments

Does this question cover just angularjs concepts or it explains a functionality from an angularjs library??
A bit of both. whenever you land in some route - its controller is instantiated. If you wish to load the same controller from the same view you need to force a reload. This answer is specific to ui-router library although this concept is available in ng-route too.

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.