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

4
  • Can you show the config and the controller??? Commented Apr 15, 2015 at 11:48
  • .state('azure.overview', { url:'/azureOverview', templateUrl :'partials/azure/azureOverview.html', controller : 'azureOverviewCtrl' }) controller $scope.init() { get the data from server } Commented Apr 15, 2015 at 12:07
  • whay are you passing .flavors as a statename Commented Apr 15, 2015 at 12:14
  • sorry i have updated code see now Commented Apr 15, 2015 at 12:20

3 Answers 3

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.

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

Comments

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

10 Comments

it is reloading but ui-sref-active is not working i have edited in plunker also but it is not working can you give sol for this Thanks in advance
@ Radim sure but i need sol plz
I udpated the answer, and created a plunker for you, with your stuff
plunker url please I have seen above plunker but that is not updated
i got ur plunker but the blue is not added when click on Flavors reloading
|
0

The native, built-in functionality of ui-router is:

when navigating among children, form one child state to another child, parent is NEVER reloaded

unless we will explicitly change that built in behaviour, e.g. via decorator as you did and force the reload with passing these options:

 { reload: true} 

You can also find similar type of solution in this post AngularJS UI Router $state reload child state only

5 Comments

correct but i want reload same state how can I do that ?
<li ui-sref=".flavors({updater : ($stateParams.updater + 1) })" ui-sref-active="currentState">reload</li> using this snippet i handled the reload fun. but ui-sref-active is not working]
add this to style : ui-sref-active="currentState" .currentState{ background: blue; }
i did same @Reena but its not working ui-sref-active="currentState" .currentState { font-weight: bold; }
@Lakshmi I think it might be because not in <a> tag. As I have seen many examples with this is working like plnkr.co/edit/KWxf2G9yGnOt05UbHFp9?p=preview

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.