AngularJS按钮刷新不工作状态 [英] AngularJS Button to reload state does not work

查看:210
本文介绍了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();
}

为什么没有发生,当我点击按钮? PS。我使用的UI路由器。

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屋!

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