31

How can I specify the reload option in a ui-sref markup? All the examples I see use the javascript function directly.

<a ui-sref="app.editPost({new:true}, {reload:true})">new post</a> 

Doesn't seem to work. Do I have to create a scope controller function to wrap that reload option instead?

I've also tried some answers below and it doesn't seem to work with the Ionic framework. Link to code pen sample below:

http://codepen.io/anon/pen/LERqeb

1 Answer 1

75

Use ui-sref-opts. Here you go:

<a ui-sref="app.editPost({new:true})" ui-sref-opts="{reload: true, notify: true}">new post</a> 

https://ui-router.github.io/ng1/docs/0.3.1/index.html#/api/ui.router.state.directive:ui-sref

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

9 Comments

Hey thanks for the response. I tried adding the ui-sref-opts="{reload: true}" and it doesn't seem to reload my ionic controller when I click (it navigates but doesn't trigger a re-run of the controller) - do you think it's an ionic issue or an angular issue or me not understanding reload correctly
This is working at my side. So what do you want to achieve from reload?
Which version of angular ui-router you are using?
If you are using version < 0.2.11 then add notify: true to your reload options. I've modified the same on answer.
Hey @MonkeyBonkey, after spending half an hour on your issue, I got to knwo that its by implementation. Ionic caches the state & does not destroy the scope but just disconnects it. So simple fix of your issue is to use cache: false inside your state configuration. Cheers!
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.