我的问题: 当我尝试在材质对话框中的颜色输入元素上使用ngModel时,我在chrome中收到以下警告消息:
The specified value "" does not conform to the required format. The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers.
我错了什么?或者这是来自Angular6的错误?
我的代码:
color.html
<input type="color" [(ngModel)]="color" />
app.component.html
<button (click)="openDialog()">Open Color Dialog</button>
app.component.ts
import { Component } from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(public dialog: MatDialog) { }
openDialog(): void {
const dialogRef = this.dialog.open(ColorDialogComponent);
}
}
@Component({
selector: 'app-color',
templateUrl: 'color.html',
})
export class ColorDialogComponent {
constructor(public dialogRef: MatDialogRef<AppComponent>) { }
onNoClick(): void {
this.dialogRef.close();
}
}
这不是错误,实际上是一个警告。它应该工作正常,为我工作。