如何在重新加载JS角儿状态 [英] how to reload child state in angular js
问题描述
<li ui-sref=".overview"
ui-sref-active="currentState"
ui-sref-opts="{reload:true}">Flavors</li>
配置:
.state('azure.overview', {
url:'/azureOverview',
templateUrl :'partials/azure/azureOverview.html',
controller : 'azureOverviewCtrl'
})
controller $scope.init() { }
我已经使用这个片段,但我的父母国家也重装,但我想唯一的孩子的状态重新加载
推荐答案
previously,对于这个问题:在UI路由器,如何重新决心才最本地状态一>,我创建这plunker
Previously, for this question: in ui-router, how to re-resolve only the most local state?, I created this plunker
这说明,我们可以使用 params:一个{}
来定义状态参数是不是在网址..但可以作为变换触发,迫使只是一个孩子的状态重新加载。
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
检查一下这里
这篇关于如何在重新加载JS角儿状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!