1

I need to be able to re run my controllers in a state when I do a state.go without doing a full page refresh (this re-renders my entire template).

I have a button that takes me to the same state with a parameter like so (I start off on 'State.ChildState')

$state.go('State.ChildState', { param1: $scope.param1});

When I have a new value for param1 this works perfectly since it doesn't redraw my template. When I have the same param1 value however it does not run my controller ( I think because my url route is the exact same). I tried to have a check where if param1 is equal to $stateParam.param1 then just do

$state.reload()

but this causes some really weird behavior in my controllers

I also tried

$state.transtionTo($state.current, $stateParams, {
  reload: true,
  inherit: false,
  notify: true
});

but this causes my entire template to be re rendered and it feels inconsistent with the case when the param1 value is different since that doesn't cause the template to be rerendered.

possible duplicate: Reloading current state - refresh data

Community
  • 1
  • 1
user1809913
  • 1,785
  • 1
  • 14
  • 25
  • Have you tried in your check when param1 equals to $stateParam.param1, instead of reload(), clear param1, reset it back then do $state.go (to fake a change)? Just a thought. – display name Dec 02 '14 at 22:01
  • Yeah that works, its kind of hacky though and I was hoping there was a better solution but I'm afraid there might not be. I updated to ui-router 2.13 and .reload() now works but its also causing the template to re-render. I don't understand why this happens on a .reload() but not on a .go(). Thanks though! – user1809913 Dec 02 '14 at 22:21
  • You may want to avoid using reload() if you want to keep template. I had a similar situation and I fixed it by clearing the params on button submit instead of reload or state change. It's hacky but it has less impact to the directive. Let me know if you find a better solution. :) – display name Dec 02 '14 at 22:29
  • Is your issue resolved.. ? If not then check my answer, and let me know. – Mayur Agarwal Oct 27 '17 at 06:05

0 Answers0