我在创建this plnkr时回答了此问题'AngularJS - open controller in a dialog (template loaded dynamically)'。
所有示例应用程序都是基于模板启动一个对话框,并使用它自己的控制器。对话框首次启动时,所有内容都按预期工作。但是,如果尝试重新启动对话框,解除对话框后,将显示模式背景,但不显示对话框。在javascript控制台中,您可以看到立即调用$dialog.open()
返回的承诺上的then
方法,但不会删除背景,也不会报告错误。我完全困惑。
可以在angular-ui引导程序documentation page上反复打开和关闭对话框。
我哪里错了?
HTML:
<!DOCTYPE html>
<html ng-app="plnkr">
<head>
<link data-require="[email protected]*" data-semver="2.3.2" rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" />
<script data-require="[email protected]" data-semver="1.0.7" src="http://code.angularjs.org/1.0.7/angular.min.js"></script>
<script data-require="[email protected]" data-semver="0.3.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.3.0.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
JS:
app.controller("DemoCtl", ["$scope", "$dialog", function($scope, $dialog){
$scope.launch = function() {
var d = $dialog.dialog({
backdrop: true,
keyboard: true,
backdropClick: true,
templateUrl: "dialog.html",
controller: "DialogCtl"
});
d.open().then(function(result) { console.log("d.open().then"); });
};
}]);
我叉你plunker和更新,但没能解决问题。 http://plnkr.co/edit/E6KCrZZflP8zap3F180H似乎一旦_open在第一次打开后被设置为false,它从不会被重置为打开 –
,希望有人能够让我们知道发生了什么。我同意某些事情没有正确设定,但肯定不是很明显。 – Jason