问题
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>
In the app.js file, I have this function in my controller:
$scope.reloadState = function() {
$state.go($state.current, {}, {reload: true});
}
I have also tried:
$scope.reloadState = function() {
$state.reload();
};
and:
$scope.reloadState = function() {
window.location.reload();
}
Why does nothing happen when I click the button? Ps. I am using ui-router.
回答1:
Try $state.transitionTo($state.current, {}, {reload: true})
回答2:
The simplest way to do this is traditional Javascript by using location.reload();
http://www.w3schools.com/jsref/met_loc_reload.asp
来源:https://stackoverflow.com/questions/31363435/angularjs-button-to-reload-state-does-not-work