我有以下按钮
<td mat-cell *matCellDef="let element">
<button mat-icon-button type="button" (click)="downloadStuff(element)">
<mat-icon mat-icon matTooltip="{{element.someId}}">picture_as_pdf</mat-icon>
</button>
</td>
Run Code Online (Sandbox Code Playgroud)
一切都很好,但我注意到默认情况下会概述小bug:
好的...。CSS使我可以删除以下内容的烦人的轮廓:
button:focus {
outline: none;
}
Run Code Online (Sandbox Code Playgroud)
但是然后..我仍然得到这个令人讨厌的默认背景焦点:
我在CSS中尝试了一些与叠加层和背景相关的东西,但这些似乎都没有解决这个问题。如何删除此默认背景?为什么它的默认行为如此???
我有一个简单的配置服务,已在 app.shared.module.ts 中使用 APP_INITIALIZER 令牌进行连接:
ConfigService,
{
provide: APP_INITIALIZER,
useFactory: (configService: ConfigService) =>
() => configService.getStuff(),
deps: [ConfigService],
multi: true
},
Run Code Online (Sandbox Code Playgroud)
这将执行订阅(config.service.ts):
settings: any;
getStuff() {
this.getSettings()
.subscribe(data => {
this.settings = data);
});
}
getSettings(): Observable<ISettings> {
return (this.httpClient
.get<ISettings>(this.localbaseUrl)
.pipe(
catchError(this.errorHandlerSerevice.handleError)
)) as any;
}
Run Code Online (Sandbox Code Playgroud)
然后我将此服务注入其他服务(通过它们的构造函数 - 我不喜欢),并且应用程序启动时一切正常:
constructor(){
this.settings = this.configService.settings;
}
Run Code Online (Sandbox Code Playgroud)
当我进入主页并从那里刷新应用程序时,一切都很好。调用逻辑并返回数据。然而,当我刷新使用该组件并调用构造函数的特定页面时,数据返回似乎已经很晚了,因此我在这里返回了 undefined :
this.settings = this.configService.settings;
Run Code Online (Sandbox Code Playgroud)
我猜“接线”是错误的......
有什么建议如何解决吗?
简化的情况是,在我的表单上,我有两个字段 - A 和 B。
字段 A 是必需的并已启用。字段 B 也是必需的,但由于在字段 A 中键入的数据而被禁用和仅填充(动态),在某些情况下,B 可能会被解析为 NULL。
除非填充了两个字段,否则用户应该无法提交表单,因此我需要向字段 B(禁用/动态填充)添加必需的验证。
虽然所需的验证对于启用的字段工作正常,但对于禁用的字段似乎被忽略了。
<mat-form-field>
<input name="FieldA" matInput formControlName="FieldA" placeholder="Field A" [maxLength]="6">
<mat-error *ngIf="formErrors.FieldA">{{ formErrors.FieldA }}</mat-error>
</mat-form-field>
<mat-form-field>
<input name="FieldB" matInput formControlName="FieldB" placeholder="Field B">
<mat-error *ngIf="formErrors.FieldB">{{ formErrors.FieldB }}</mat-error>
</mat-form-field>
buildForm() {
this.form = this.form.group({
FieldA: ['', [Validators.required]],
FieldB: [{ value: '', disabled: true }, [Validators.required]],
});
Run Code Online (Sandbox Code Playgroud)
有什么方法可以在 HTML 中向 FieldB 添加验证而不启用它?