0

Making a doctor's website with Angular ui-router which switches partials through ui-sref. I need the ui-sref link to reload on the pages with the javascript widgets so they upload. Here is the view:

<a ui-sref="home">

and the state router in the js file:

  .state('home', {
      url: '/home',
      templateUrl: 'Partials/partial-home.html'
     })

I tried:

ui-sref-opts="{reload: true}"

in my ui-sref but it did not reload the widget. I tried other code I found here and that didn't help either. Here is the source code for anyone who wants to see: https://github.com/EBM26

4
  • You say "it doesn't work". What does that mean? What widget are you using? Is it an Angular module or jQuery / some other javascript? Commented Oct 1, 2015 at 18:48
  • If Im not mistaken, Brian, it is calling the API from the Health Tap website and its not refreshing when I click back to the home ui-sref <script type="text/javascript" src="https://www.healthtap.com/widget/askdoc.js" ></script> <div id="htapWidgetAskdoc" data-doctor="26158967" data-just_answers="true" data-color="rgb(246, 252, 208)" class="col-xs-4"><span>Powered by</span> <a href="https://www.healthtap.com">HealthTap</a> <div id="HtInboundLinks"> With content from: <a href="https://www.healthtap.com/experts/26158967">Dr. Danny Benmoshe's Virtual Practice</a><br></div> </div> Commented Oct 1, 2015 at 19:11
  • Open the website in Chrome, on your keyboard do (CMD | CTRL) + OPTION + i > Go to the "Network" tab in your debugger panel > Look to see if there is an http transaction (either API call or script download) that matches what you want to be making Commented Oct 1, 2015 at 20:40
  • I don't think the question is clear enough, why do you want to reload the content when you go back? Are the widgets part of angular or is it another library? Commented Oct 1, 2015 at 21:09

1 Answer 1

0

If you want to force the reload on the view, I would just do it on the controller. This breaks the whole point of a SPA.

See this question. "ui-sref" does not refresh the "ui-view"(its controller does not rerun) when a link is clicked twice

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

2 Comments

Thanks Rick, saw that post and tried it on my code but it wouldn't reload the widget. I put the reload function in my state router. Maybe you meant that I should make a controller as well?
Yes, it's a bit hackish but I think that's what you want to do. You could also do it on the controller by just using plain javascript location.reload();

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.