Javascript 隐藏引导3模式&;AngularJS重定向($location.path)
我在AngularJS应用程序中使用Bootstrap3模式作为对话框确认。当我隐藏模态并重定向时,模态的背景仍然保留Javascript 隐藏引导3模式&;AngularJS重定向($location.path),javascript,jquery,twitter-bootstrap,angularjs,twitter-bootstrap-3,Javascript,Jquery,Twitter Bootstrap,Angularjs,Twitter Bootstrap 3,我在AngularJS应用程序中使用Bootstrap3模式作为对话框确认。当我隐藏模态并重定向时,模态的背景仍然保留 $scope.delete = function () { DataService.delete() .then(function () { $("#delete").modal("hide"); $location.path("/"); }); } 我已尝试在“隐藏”上使用回调 $("#delete").on('hidden
$scope.delete = function () {
DataService.delete()
.then(function () {
$("#delete").modal("hide");
$location.path("/");
});
}
我已尝试在“隐藏”上使用回调
$("#delete").on('hidden.bs.modal', function () {
$location.path("/");
}
但这方面的拖延太多了
有更好的方法吗
但这方面的拖延太多了
您可能忘记调用$scope.$apply()
。尝试将其更改为以下值(如果延迟是唯一的问题),延迟应正常:
$("#delete").on('hidden.bs.modal', function () {
$location.path("/");
$scope.$apply();
});
与Angular交互的所有在Angular外部调用的代码(在本例中来自jQuery事件)都应该调用
$apply()
。您还可以查看Angular ui团队为引导所做的Angular指令