AngularMaterial:mat-error封装问题
创始人
2024-10-28 08:01:12
0

在使用Angular Material中的mat-error组件时,可能会遇到该组件无法封装在自定义组件中的问题。解决方法如下:

1.使用ng-content将mat-error组件作为子组件在父组件中引用。例如:

This field is required

2.设置ViewEncapsulation.None,如下所示:

import { Component, ViewEncapsulation } from '@angular/core';

@Component({ selector: 'app-form-field', templateUrl: './form-field.component.html', styleUrls: ['./form-field.component.scss'], encapsulation: ViewEncapsulation.None }) export class FormFieldComponent {}

然后,在自定义组件模板中,不要再使用Encapsulation.None指令,否则会破坏组件封装性。

相关内容

热门资讯

经核实!wepoker有没有插... 经核实!wepoker有没有插件(透视)蜀山四川免费辅助软件下载(原来存在有辅助修改器)-哔哩哔哩1...
今日!xpoker辅助怎么用(... 今日!xpoker辅助怎么用(透视)情怀国粹麻将神器(确实真的是有辅助软件)-哔哩哔哩;1、情怀国粹...
透视代打!aapoker辅助器... 透视代打!aapoker辅助器是真的吗(透视)丫丫陕西扑克绿色透视(本来是真的辅助软件)-哔哩哔哩1...
透视软件!wepoker破解版... 透视软件!wepoker破解版内购(透视)兴动互娱游戏辅助器好用吗(果然真的有辅助软件)-哔哩哔哩1...
据了解!wpk刷入池率脚本(透... 据了解!wpk刷入池率脚本(透视)新蜜瓜大厅免费控制器(其实存在有辅助app)-哔哩哔哩1、任何新蜜...
今日!aapoker透视怎么用... 今日!aapoker透视怎么用(透视)传送屋有挂吗(真是是真的辅助工具)-哔哩哔哩1、传送屋有挂吗免...
透视辅助!wepoker科技辅... 透视辅助!wepoker科技辅助器(透视)wepoker辅助器是真的吗(切实是真的辅助下载)-哔哩哔...
透视真的!wepoker透视辅... 透视真的!wepoker透视辅助下载(透视)天酷辅助器(真是真的有辅助神器)-哔哩哔哩1、下载好天酷...
最终!wepoker国外版透视... 最终!wepoker国外版透视(透视)hhpoker大菠萝有没有作比(本来真的是有辅助安装)-哔哩哔...
透视线上!wepoker辅助工... 透视线上!wepoker辅助工具(透视)余干中至小程序辅助器免费(果然有辅助软件)-哔哩哔哩该软件可...