我正在从控制器中调用模式弹出窗口。第一次可以正常运行,但第二次不显示。这是该节目的代码
$scope.showAdvanced = function (ev) {
var scopeVar = $scope;
console.log('$mdDialog');
console.log($mdDialog);
$mdDialog.show({
controller: DialogController,
templateUrl: 'dialog1.tmpl.html',
parent: angular.element(document.body),
scope: $scope,
targetEvent: ev,
clickOutsideToClose: true
}).then(function (result) {
//$scope = $scope.$parent;
console.log($scope);
});
};
这是我在DialogController中的hide函数。
$scope.hide = function () {
console.log('hide called');
$mdDialog.hide();
console.log('hide completed');
};
隐藏成功执行,然后在show中定义回调,该回调将打印当前范围。如果我删除scope:$ scope并放入transclude:true,则尽管您可以多次显示和隐藏它,但它不会在对话框控制器中显示数据。
将preserveScope: true
添加到模态选项。对话会删除其默认关闭范围。