我正在使用ngDialog
完全正常工作而不添加任何setDefault
属性,一旦在app.config中,如果我设置了任何属性,它就不会渲染。
我想阻止点击esc
或对话框以外的任何地方关闭对话框。
ngDialog.open({
template: 'app/components/pages/page-locations/compare-location.html',
className: 'ngdialog-theme-plain',
scope: $scope
});
这是完全正常的,直到我添加以下代码:
var app = angular.module('myApp', ['ngDialog']);
app.config(['ngDialogProvider', function (ngDialogProvider) {
ngDialogProvider.setDefaults({
className: 'ngdialog-theme-plain',
plain: true,
showClose: false,
closeByDocument: false,
closeByEscape: false
});
}]);
我从文档中获得了上述代码,并更改了className
。目前它作为链接而不是模态内容呈现。
<div class="ngdialog-content" role="document">
app/components/pages/page-locations/compare-location.html
</div>
答案 0 :(得分:0)
我想这个问题依赖于此
// you're calling html file rather than dialog id
template: 'app/components/pages/page-locations/compare-location.html'
您应该在视图中定义对话框ID
// Example modal template
<script type="text/ng-template" id="modalDialogId">
<div class="ngdialog-message">
<h3>ngDialog modal example</h3>
<div class="ngdialog-buttons">
<button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="confirm(confirmValue)">Confirm</button>
<button type="button" class="ngdialog-button ngdialog-button-secondary" ng-click="closeThisDialog('button')">Cancel</button>
</div>
</script>
并在模板中调用它
ngDialog.open({
template: 'modalDialogId',
className: 'ngdialog-theme-plain',
scope: $scope
});
答案 1 :(得分:0)
我发现的解决方案是:
ngDialog.open({
template: 'app/components/pages/page-locations/info-compare.html',
className: 'ngdialog-theme-plain',
scope: $scope,
closeByDocument: false,
closeByEscape: false
});
由于我的对话框太多而且代码量很大,我不想在我的视图中添加脚本。