0

I have just created a page using angular 6 and i want to implement material view for the UI. While implementing i'm getting the below error.

I tried added the material.js lib but no luck

Uncaught Error: Template parse errors:

 'mat-icon' is not a known element:
1. If 'mat-icon' is an Angular component, then verify that it is part of this module.
2. If 'mat-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("eld>
    <input matInput placeholder="Enter your password" [type]="hide ? 'password' : 'text'">
    [ERROR ->]<mat-icon matSuffix (click)="hide = !hide">{{hide ? 'visibility_off' : 'visibility'}}</mat-icon>
  </"): ng:///AppModule/ApplicationComponent.html@4:4
'mat-form-field' is not a known element:
1. If 'mat-form-field' is an Angular component, then verify that it is part of this module.
2. If 'mat-form-field' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<h1>Products List</h1>
<div class="example-container">
  [ERROR ->]<mat-form-field>
    <input matInput placeholder="Enter your password" [type]="hide ? 'password' : 't"): ng:///AppModule/ApplicationComponent.html@2:2
    at syntaxError (compiler.js:2547)
    at TemplateParser.push../node_modules/@angular/compiler/fesm5/compiler.js.TemplateParser.parse (compiler.js:19495)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._parseTemplate (compiler.js:25041)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileTemplate (compiler.js:25028)
    at compiler.js:24971
    at Set.forEach (<anonymous>)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileComponents (compiler.js:24971)
    at compiler.js:24881
    at Object.then (compiler.js:2538)
    at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:24880)
georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • Possible duplicate of [Template parse errors: 'mat-icon' is not a known element](https://stackoverflow.com/questions/50190337/template-parse-errors-mat-icon-is-not-a-known-element) – BadPiggie Nov 22 '18 at 17:15
  • I have tried added it but still im getting error. ERROR in src/app/app.module.ts(8,33): error TS2307: Cannot find module '@angular/material/button'. src/app/app.module.ts(10,31): error TS2307: Cannot find module '@angular/material/icon'. I have ran npm install when i created the project.. i have all dependency in my project path – Steve rogers Nov 22 '18 at 17:27
  • Can you share your all codes clearly? – BadPiggie Nov 22 '18 at 17:31

1 Answers1

0

In angular 6 you don't have to add .js file for using angular material you just have to install it through npm. Try following the angular material getting started guide it should work.

Yatharth Varshney
  • 1,973
  • 20
  • 22