1

I'm using angular-ui-router to manage router of my webapp, here got a question...

How can I do reload when I click the same link, currently when I click a link twice that just load one time...

5
  • Can you elaborate on your question? Share some code that you have that is relevant to the question. Commented Apr 15, 2016 at 7:02
  • is $state.reload() is what you are looking for? Scroll to the reload method in the documentation and see whether it's what you need Commented Apr 15, 2016 at 7:11
  • See this: stackoverflow.com/a/24458344/1414641 Commented Apr 15, 2016 at 8:40
  • Reloading is probably not what you want to do. It is considered bad practice and there is probably a better way to achieve your desired result. Please post some more details about your problem to get a better answer. Commented Apr 15, 2016 at 8:58
  • Please have a look at the following link : stackoverflow.com/questions/21714655/… . This is what you need. Commented Apr 15, 2016 at 9:42

1 Answer 1

4

Probably the cleaner approach would be the following :

<a data-ui-sref="awesomeStateName" data-ui-sref-opts="{reload: true}">Details State</a>

We can reload the state from the HTML only.

Sign up to request clarification or add additional context in comments.

5 Comments

so do I need to add something like: params: {reload: false} into stateProvider of this relative router?
You just need to use 'data-ui-sref-opts="{reload:true}" in your anchor link. This directive is provided by the ui-router itself where you can actually reload the state on click of this particular anchor link.
Thank you for your answer, It's working! BTW what different bewteen 'ui-sref' and 'data-ui-sref'
since ui-sref, ng-app or any other directive are not HTML5 compatible. So to make it HTML5 compatible we prefix 'data-' before all the angular directives. It is considered to be a good practice. And HTML5 compilers does't throw warnings. Hope that answers your query.
I see!Thank you every much!

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.