Friday, March 1, 2019

compiler.js:1021 Uncaught Error: Template parse errors: 'mat-form-field' is not a known element:


Hi Guys ,

Today I have faced this error :

compiler.js:1021 Uncaught Error: Template parse errors: 'mat-form-field' is not a known element:

The solution to this is to import the required mat modules in app.module.ts  highlighted below .

----------------app.module.ts-----------------------------------------------------------------------------
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatButtonModule, MatInputModule, MatCardModule } from '@angular/material';
import 'hammerjs';

import { AppComponent } from './app.component';
import { LoginComponent } from './login/login.component';

@NgModule({
  declarations: [
    AppComponent,
    LoginComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    ReactiveFormsModule,
    BrowserAnimationsModule,
    MatButtonModule,
    MatInputModule,
    MatCardModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
------------------------------------------------------------------------------------------------------
Test your understanding
angular-cli.json was deprecated in which version ?
v5
v4
v6
v7
Info
Next

No comments:

Post a Comment

ec2-user@ec2 Permission denied