我正在使用Angular UI路由器,并希望重新加载当前状态并刷新所有数据/重新运行控制器以获取当前状态。
如何使用$state.reload()
和$stateParams
使用新数据重新加载状态?
app.js
.state('app.editControl', {
url: '/edit/control',
params: { controlId: null,processId: null, from: null, controlInProcessKey:null, refresh:null},
templateUrl: 'views/control/createNewControl.html',
controller: 'CreateControlCtrl',
data: {
authenticate: true
},
ctrl.js
$scope.updateCallBack = function() {
setInterval(function() {
$scope.statusInfo = '';
}, 1000);
if ($scope.editControlToRisk) {
console.log('EDITCONTROL');
if ($scope.controlDTO.controlInProcessDTO.processKey) {
$state.go('app.alignCtrlToProcess', {
controlId: $scope.controlDTO.controlKey,
controlInProcessKey: $scope.controlDTO.controlInProcessDTO.controlInProcessKey,
processId: $scope.controlDTO.controlInProcessDTO.processKey
});
} else {
$state.go('app.home');
}
} else {
console.log('EDIT');
$state.go($state.current, {
controlId: $stateParams.controlId
}, {
reload: true
});
$scope.selectedAlignProcesses = new Date().getTime();
}
};
答案 0 :(得分:1)
你可以尝试
$state.go($state.current, $stateParams, {reload: true});// can check with inherit {reload: true, inherit: false}
您应该在$scope.selectedAlignProcesses = new Date().getTime();
$state.go