Javascript 对话框:设置默认值的问题
我使用的是Javascript 对话框:设置默认值的问题,javascript,angularjs,ng-dialog,Javascript,Angularjs,Ng Dialog,我使用的是ngDialog,它在不添加任何setDefault属性的情况下工作得非常好,一旦在app.config中设置了任何属性,它就不会呈现 我想阻止对话框在单击esc或对话框以外的任何位置关闭 ngDialog.open({ template: 'app/components/pages/page-locations/compare-location.html', className: 'ngdialog-theme-plain', scope: $scope }
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>
app/components/page/page locations/compare-location.html
我想问题在于此
// 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: 'app/components/pages/page-locations/info-compare.html',
className: 'ngdialog-theme-plain',
scope: $scope,
closeByDocument: false,
closeByEscape: false
});
因为我有太多包含大量代码的对话框,所以我不想在我的视图中添加脚本。你能创建一个plunker吗?如果你只有一个或少数对话框,为什么不直接在
ngDialog.open({…})中添加closeByEscape:false
和任何其他设置代码>@KScandrett好了,伙计。。!!我试图解决的问题是阻止关闭esc
或文档单击上的对话框。这将是解决方案的一部分,但我有太多的对话框和太多的代码。您可以使用ng include将多个脚本/模板包含在一起。这很有意义。非常感谢。
ngDialog.open({
template: 'app/components/pages/page-locations/info-compare.html',
className: 'ngdialog-theme-plain',
scope: $scope,
closeByDocument: false,
closeByEscape: false
});