1
<li ui-sref=".overview" 
    ui-sref-active="currentState"
    ui-sref-opts="{reload:true}">Flavors</li>

Config:

 .state('azure.overview', {
    url:'/azureOverview', 
    templateUrl  :'partials/azure/azureOverview.html', 
    controller : 'azureOverviewCtrl' 
  })        
controller $scope.init() { }

I have used this snippet but my parent state also reloading but i want only child state to reload

Lakshmi
  • 175
  • 1
  • 4
  • 16

3 Answers3

2

@Lakshmi You may have your answer here:

As of 0.2.14 you also have an option to just reload the current state and not it's parent.

So $state.go(people.search, {}, {reload: true}); would reload the people state as well as all its childs.

While $state.go(people.search, {}, {reload: "people.search"}); would not reload the people state but would reload people.search and its childs.

Shyamal Parikh
  • 2,988
  • 4
  • 37
  • 78
1

There is a working plunker

Previously, for this question: in ui-router, how to re-resolve only the most local state?, I created this plunker

which shows, that we can use params : {} to define state parameter which is not in the url.. but could be used as "change trigger", forcing just a child state to reload.

Here we can see these states:

  .state('azure', {
      url: "/azure",
      templateUrl: 'tpl.azure.html',
      controller: 'azureOverviewCtrl',
  })
  .state('azure.overview', {
      url: "/overview",
      params: { updater : 1, },
      templateUrl: 'tpl.overview.html',
      controller: 'OverCtrl',
  })

Now, we can create this reload link, which simply sends incremented updater number:

<li ui-sref-active="blue">
  <a ui-sref="azure.overview({updater: ($stateParams.updater + 1) })" 
  >Flavors <b>reloading</b></a></li>

And with this incrementation, we can be sure, that reload link - will reload this child state

Check it here

Community
  • 1
  • 1
Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
  • Yes you may now it ;) The trick is - UI-Router needs direcitve **ui-sref** to be able to use *ui-sref-active*. The ui-sref, must be targeting the state - which is current. That means, that with one of these... we say to UI-Router ... we are really on current state. So - this is good for ui-sref-active. The second - which has different udpater value (different then current stat has) - is in fact there for us ... to really do redirect. So - both are needed, each for different purpose... taht's the angular world of directives ;) hope it helps. Good luck – Radim Köhler Apr 15 '15 at 13:03
  • oh got it , really really i am very thankful for your efforts... :) ;) – Lakshmi Apr 15 '15 at 13:08
  • Well, if that helped, it would be nice if your accept this answer as helpful, maybe even upvote it ;) because that's how it is working here.. – Radim Köhler Apr 15 '15 at 13:10