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

EBM26
  • 1
  • 2
  • 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? – Brian Oct 01 '15 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 `` `
    Powered by HealthTap
    `
    – EBM26 Oct 01 '15 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 – Brian Oct 01 '15 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? – Rick Oct 01 '15 at 21:09

1 Answers1

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

Community
  • 1
  • 1
Rick
  • 12,606
  • 2
  • 43
  • 41
  • 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? – EBM26 Oct 01 '15 at 23:19
  • 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();` – Rick Oct 02 '15 at 04:36