在我的自定义元素中使用 mat-select 元素时,选项显示在 HTML 中创建的影子 dom 之外,这意味着选项不会显示在选择控件的正下方。
据我所知,我需要将 ViewEncapsulation 设置为 ShadowDom。只有这样我的自定义元素才能在所有浏览器中工作。所以我的问题的解决方案应该是使用 ShadowDom。
Component({
selector: 'app-survey',
templateUrl: './survey.component.html',
styleUrls: ['./survey.component.css'],
encapsulation: ViewEncapsulation.ShadowDom
})
<mat-form-field #ff>
<mat-select placeholder="Auswahl ERP System" [(ngModel)]="erpSystem">
<mat-option *ngFor="let choice of erpSystemAuswahl" [value]="choice">
{{choice}}
</mat-option>
</mat-select>
</mat-form-field>
我希望选项与选择元素一起显示。如何更改选项的行为以正确显示?
最佳答案
Elements use
除了要求 Angular Material 团队添加插槽外,我不确定您还能做什么。我正忙着尝试使用指令动态地向 Material 组件添加插槽(不确定它是否有效)
关于angular - 在自定义元素(Web 组件)中使用 mat-select 打开影子 DOM 外部的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54110158/
相关文章:
python - Pygame OpenGL 3D 立方体滞后
visual-studio - Visual Studio 安装项目 - 如何避免重复条目?
amazon-web-services - AWSLambdaClient 调用给出异常 : com
mysql - 有什么方法可以将 MySQL 转储转换为 YAML Alice Fixtures
python - 如何通过 odoo 中的 xmlrpc 为产品提供批号/序列号
php - 我的 Laravel 应用程序在 Google Cloud 上有问题。无法打开流或文件