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指令,否则会破坏组件封装性。

相关内容

热门资讯

透视指南书!pokemmo免费... 透视指南书!pokemmo免费脚本(透视)哈糖大菠萝能开挂吗(辅助)切实真的是有技巧(哔哩哔哩)1、...
透视办法!菠萝辅助器免费版的功... 透视办法!菠萝辅助器免费版的功能介绍(透视)拱趴大菠萝万能挂(辅助)一贯一直都是有神器(哔哩哔哩)暗...
透视举措!xpoker辅助控制... 透视举措!xpoker辅助控制(透视)大菠萝免费辅助(辅助)原来是真的有软件(哔哩哔哩)大菠萝免费辅...
透视窍门!pokemmo手机脚... 透视窍门!pokemmo手机脚本(透视)werplan有挂吗(辅助)其实真的是有app(哔哩哔哩)1...
透视方针!哈糖大菠萝怎么开挂(... 透视方针!哈糖大菠萝怎么开挂(透视)佛手在线有挂吗(辅助)一直一直都是有软件(哔哩哔哩)1、很好的工...
透视绝活儿!pokermast... 透视绝活儿!pokermaster辅助器(透视)pokemmo手机版脚本免费(辅助)都是一直总是有a...
透视法子!智星菠萝辅助(透视)... 透视法子!智星菠萝辅助(透视)佛手大菠萝有挂吗(辅助)总是存在有神器(哔哩哔哩)1、佛手大菠萝有挂吗...
透视机巧!sohoo poke... 透视机巧!sohoo poker辅助器(透视)xpoker怎么作必弊(辅助)确实存在有技巧(哔哩哔哩...
透视手册!来玩德州破解器(透视... 透视手册!来玩德州破解器(透视)xpoker辅助助手(辅助)果然真的是有工具(哔哩哔哩)1、透视手册...
透视窍门!哈糖大菠萝有挂吗(透... 透视窍门!哈糖大菠萝有挂吗(透视)德州局脚本(辅助)一贯是真的有插件(哔哩哔哩)1、不需要AI权限,...