[英]Angular change focus color for mat-label inside mat-form-field
[英]Angular Problem with mat-form-field/mat-label
我开始学习 Angular 材料,但我在从他们的站点添加示例时遇到了问题。
我在 html 文件中添加了:
<mat-form-field class="example-form-field">
<mat-label>Clearable input</mat-label>
<input matInput type="text" [(ngModel)]="value">
<button *ngIf="value" matSuffix mat-icon-button aria-label="Clear" (click)="value=''">
<mat-icon>close</mat-icon>
</button>
</mat-form-field>
而且我几乎没有错误:'mat-form-field' 不是已知元素:
我的 app.module.ts 文件:
import {MatInputModule} from '@angular/material/input';
import {Component} from '@angular/core';
import { NgModule} from '@angular/core';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { BrowserModule } from '@angular/platform-browser';
import { MatRippleModule } from '@angular/material/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon'
import {MatButtonModule} from '@angular/material/button';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';
@NgModule ({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [
MatSlideToggleModule,
BrowserModule,
FormsModule,
MatFormFieldModule,
MatButtonModule,
MatIconModule,
MatInputModule,
MatRippleModule
]
})
class AppModule {}
@Component({
selector: 'input-clearable-example',
templateUrl: './okno_testowe.html',
styleUrls: ['./log.css'],
})
export class InputClearableExample {
value = 'Clear me';
}
和 css:
.example-form-field {
width: 200px;
}
这里可能是什么问题? 我认为我犯了一些简单的错误,因为我才刚刚迈出这些技术的第一步
@NgModule ({
imports: [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
MatFormFieldModule,
MatButtonModule,
MatIconModule,
MatInputModule,
MatRippleModule
],
declarations: [InputClearableExample],
bootstrap: [InputClearableExample],
})
export class AppModule {}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.