[英]Angular ngDialog : Issues with setDefaults
I'm using ngDialog
which works completly fine without adding any setDefault
properties, once in the app.config if I set any properties, it does not render. 我正在使用ngDialog
,它完全可以正常工作,而无需添加任何setDefault
属性,如果我设置了任何属性,则一旦在app.config中,它就不会呈现。
I want to prevent dialog box from closing on click of esc
or anywhere other than the dialog box. 我想防止在单击esc
或对话框以外的任何位置时关闭对话框。
ngDialog.open({
template: 'app/components/pages/page-locations/compare-location.html',
className: 'ngdialog-theme-plain',
scope: $scope
});
This was working completely fine until I added the below code: 直到我添加以下代码,此方法才能正常工作:
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
});
}]);
I got the above code from the documentation, and I changed the className
. 我从文档中获得了上面的代码,并更改了className
。 At the moment it renders as a link instead of modal content. 目前,它呈现为链接而不是模式内容。
<div class="ngdialog-content" role="document">
app/components/pages/page-locations/compare-location.html
</div>
I guess the issue relies here 我想问题在于
// you're calling html file rather than dialog id
template: 'app/components/pages/page-locations/compare-location.html'
You should define dialog id in your view 您应该在视图中定义对话框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>
and call it in the template like this 然后像这样在模板中调用它
ngDialog.open({
template: 'modalDialogId',
className: 'ngdialog-theme-plain',
scope: $scope
});
The solution what I found out was : 我发现的解决方案是:
ngDialog.open({
template: 'app/components/pages/page-locations/info-compare.html',
className: 'ngdialog-theme-plain',
scope: $scope,
closeByDocument: false,
closeByEscape: false
});
Since I have too many dialog boxes which has a large amount of code, I did not want to add as a script in my view. 由于我有太多的对话框,其中包含大量的代码,因此我不想在视图中添加为脚本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.