0

I have these states:

.state('message', {
  url : '/message'
  templateUrl : 'views/message.html',
  controller : 'messageController'
})
.state('news', {
  url : '/news'
  templateUrl: 'views/news.html',
  controller : 'newsController'
})

In messageController i append some query string in url like /message?contact=some.

problem is that when go to news state with ui-sref, query strings does not cleared and it redirects to /news?contact=some.

i tried to clear $location.search in stateChangeEvent.

any help?

1 Answer 1

1

You can do one of the following:

Use query params:

 .state('message', {
     url: "/message?contact"
     // will match to url of "/message?contact=value"
     ...
 }

Use state params: (better for ui-sref linking)

.state('message', {
    url: "/message/:contact",
    // can be accessed by $stateParams service - $stataParams['contact']
    ...
 }
Sign up to request clarification or add additional context in comments.

Comments

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.