我在我的指令代碼一樣,打開一個模式:引導模式,使滾動條消失
var modalInstance = $modal.open({
templateUrl: "app/templates/modal-assign.html",
controller: "assignModalController",
resolve: {
"call": function() {
return $scope.call;
}
}
});
但我有我的assignModalController驗證,我需要關閉我的模式: AssignValidatorService .validateOpeningModal($範圍)。然後(函數(驗證){ 如果(validation.isValid){$ scope.handleCancel(validation.msg!);} $ rootScope.setBusyIndicator(假);} ,功能( ){ $ rootScope.setBusyIndicator(false); });
和我handleCancel:
$scope.handleCancel = function(message) {
$log.info(filename + " - handleCancel");
$modalInstance.dismiss(message);
};
因此,模態正確關閉,但屏幕滾動條消失。
經過很長時間尋找答案,我想出了bootstrap在<body>
標記中添加一個模式打開的類。當這個模式關閉時,bootstrap會從<body>
中刪除那個類。我檢查了DOM,並看到<body>
中的模態公開課,我手動移除了屏幕滾動條並重新出現。
我試圖通過代碼在handleCancel功能上許多方法來去除類,像這樣:
$scope.handleCancel = function(message) {
$log.info(filename + " - handleCancel");
angular.element(document).find("body").removeClass();
$modalInstance.dismiss(message);
};
...但沒有成功!
任何想法?