AngularJS 按钮重新加载状态不起作用 [英] AngularJS Button to reload state does not work
本文介绍了AngularJS 按钮重新加载状态不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在前端 (AngularJS) 上有一个按钮来刷新对数据库所做的更改.我在 html 中尝试了以下内容:
I want to have a button on the front end (AngularJS) that refreshes the changes made to the database. I have tried the following in the html:
<button ng-click="reloadState" data-translate> Refresh Database </button>
在 app.js 文件中,我的控制器中有这个函数:
In the app.js file, I have this function in my controller:
$scope.reloadState = function() {
$state.go($state.current, {}, {reload: true});
}
我也试过:
$scope.reloadState = function() {
$state.reload();
};
和:
$scope.reloadState = function() {
window.location.reload();
}
为什么当我点击按钮时什么也没有发生?附言.我正在使用 ui-router.
Why does nothing happen when I click the button? Ps. I am using ui-router.
推荐答案
最简单的方法是传统的 Javascript,使用 location.reload();
The simplest way to do this is traditional Javascript by using location.reload();
http://www.w3schools.com/jsref/met_loc_reload.asp
这篇关于AngularJS 按钮重新加载状态不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文