简体   繁体   English

如何根据对话框内容中使用的下拉组件调整angular-material2的md-dialog-container的大小

[英]How to resize md-dialog-container of angular-material2 based on dropdown component used in dialog content

I am using Angular Material2's dialog component. 我正在使用Angular Material2的对话框组件。 Inside dialog, I am using input fields and angular2-dropdown-multiselect . 在对话框中,我使用输入字段和angular2-dropdown-multiselect

Now when I open drop down, it adds the scrollbar to the dialog box. 现在,当我打开下拉菜单时,它将滚动条添加到对话框中。

在此处输入图片说明

I want to get dialog should resize automatically rather than providing the scroll bar if I open multi-select dropdown. 我想让对话框在打开多选下拉菜单时应自动调整大小,而不是提供滚动条。

I have tried giving max-height property to dialog box, but not working :( 我尝试将max-height属性赋予对话框,但不起作用:(

Add a click event to your search element: 在您的搜索元素中添加点击事件:

<div class="form-group" (click)="autoScroll($event)">
    <ss-multiselect-dropdown></ss-multiselect-dropdown>
</div>

In controller: 在控制器中:

autoScroll(event): void {
  let parent = document.getElementById("ng2Dialog");
  parent.scroll(0, event.target.getBoundingClientRect().top);
}

You can change parent with Angular Material2's dialog. 您可以使用Angular Material2的对话框更改父级。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM