Angular材料形式字段无效
我正在关注此 https://material.angular.io/compar.io/components/form-firfield/概述 但是在我的代码表格字段中行为没有更改,也没有出现标签 例如,如果外观填充,看起来像默认表单
<mat-form-field appearance="fill">
<mat-label>First Name</mat-label>
<input placeholder="FirstName<" formControlName="FName">
</mat-form-field>
屏幕 [1]: https://i.sstatic.net/6ihkn.png 但是,即使我更改外观=“标准”或外观=“轮廓”它不会改变行为 app-module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MessageFormComponent } from './message-form/message-form.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS} from '@angular/material/form-field';
import {MatButtonModule} from '@angular/material/button';
import {FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import {MatInputModule} from '@angular/material/input'
@NgModule({
declarations: [
AppComponent,
MessageFormComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
MatFormFieldModule,
MatButtonModule,
MatInputModule,
HttpClientModule
],
providers: [{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'fill'}}],
bootstrap: [AppComponent]
})
export class AppModule { }
有人可以告诉需要做什么
I am following this https://material.angular.io/components/form-field/overview
but in my code form fields behaviour isn't changing also label isn't appearing
for example if the appearance is fill it look like as default form
<mat-form-field appearance="fill">
<mat-label>First Name</mat-label>
<input placeholder="FirstName<" formControlName="FName">
</mat-form-field>
Screen
[1]: https://i.sstatic.net/6ihkn.png
but even I change the appearance="standard" or appearance="outline" it doesn't change the behaviour
App-module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { MessageFormComponent } from './message-form/message-form.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatFormFieldModule, MAT_FORM_FIELD_DEFAULT_OPTIONS} from '@angular/material/form-field';
import {MatButtonModule} from '@angular/material/button';
import {FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import {MatInputModule} from '@angular/material/input'
@NgModule({
declarations: [
AppComponent,
MessageFormComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
FormsModule,
ReactiveFormsModule,
MatFormFieldModule,
MatButtonModule,
MatInputModule,
HttpClientModule
],
providers: [{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'fill'}}],
bootstrap: [AppComponent]
})
export class AppModule { }
can someone tell what needs to be done
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你们都很好。只是缺少
matinput
您的&lt; Input&gt;
上的指令You are all good. just missing
matInput
directive on your<input>