重新加载当前状态 - 刷新数据 [英] Reloading current state - refresh data

查看:273
本文介绍了重新加载当前状态 - 刷新数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了棱角分明的UI路由器和希望加载当前状态,并刷新所有数据/重新运行控制器的当前状态和它的母公司。

I'm using Angular UI Router and would like to reload the current state and refresh all data / re-run the controllers for the current state and it's parent.

我有3个州级: directory.organisations.details

directory.organisations 包含的组织的名单表。点击表格中的负载的项目 directory.organisations.details 与$ StateParams通过该项目的ID。所以在细节状态我加载细节此项目,对其进行编辑,然后保存数据。所有罚款为止。

directory.organisations contains a table with a list of organisations. Clicking on an item in the table loads directory.organisations.details with $StateParams passing the ID of the item. So in the details state I load the details for this item, edit them and then save data. All fine so far.

现在我需要重新加载此状态,并刷新所有数据。

Now I need to reload this state and refresh all the data.

我曾尝试:

 $state.transitionTo('directory.organisations');

哪个进入到母体状态,但不会重新加载控制器,我想,因为路径并没有改变。理想的情况是我只是想留在 directory.organisations.details 状态,并刷新父的所有数据了。

Which goes to the parent state but doesn't reload the controller, I guess because the path hasn't changed. Ideally I just want to stay in the directory.organisations.details state and refresh all data in the parent too.

我也尝试:

$state.reload()

我已经看到了这对$ state.reload的API WIKI(错误与控制器重新实例,现在,很快就固定)。

I have seen this on the API WIKI for $state.reload "(bug with controllers reinstantiating right now, fixing soon)."

任何帮助将是AP preciated?

Any help would be appreciated?

推荐答案

这个解决方案工作于AngularJS V.1.2.2:

This solution works in AngularJS V.1.2.2:

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

这篇关于重新加载当前状态 - 刷新数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆