【发布时间】:2015-09-04 12:53:54
【问题描述】:
下面是我的代码:
app.controller('lookupMasterController', [
'$scope', '$routeParams', '$location', '$modal', 'lookupService', function ($scope, $routeParams, $location, $modal, lookupService) {
$scope.openCreatePopup = function () {
var modalInstance = $modal.open({
animation: true,
templateUrl: 'app/popups/add-lookup.html',
controller: function ($scope, $modalInstance, $location, $routeParams, lookupService) {
$scope.cancel = function () {
$modalInstance.close();
}
$scope.addLookup = function () {
$scope.lookup.lookUpConfigId = $routeParams.lookupMasterId;
lookupService.save($scope.lookup).$promise.then(
function (value) {
$location.path('/edit-lookup/' + $routeParams.lookupMasterId);
$scope.$apply();// Even this is not working.
// Tried the below as well:
//$scope.$apply(function () {
// $location.path('/edit-lookup/' + //$routeParams.lookupMasterId);
// });
$modalInstance.close();
},
function (error) { /*Do something with error*/
alert(error.message);
});
}
},
size: 'lg'
});
}
}
]);
我正在打开一个弹出窗口以添加新查找,然后重新加载页面以查看更改。但问题是:$location.path('url'); 不工作。
【问题讨论】:
-
使用 $route.reload() 来重新加载当前页面:stackoverflow.com/questions/16703215/…
-
效果不佳..
标签: javascript jquery angularjs redirect