2

I am using Angular 9 with Angular Material 9.2.4.

I am trying to use the mat-tab-group in my component.html, but I keep getting the error

'mat-tab-group' is not a known element:
1. If 'mat-tab-group' is an Angular component, then verify that it is part of this module.
2. If 'mat-tab-group' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng(0)

I have installed Angular material using the following command

ng add @angular/material

My package.json is as follows:

"dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "^9.0.0",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "~9.0.0",
    "@angular/compiler": "~9.0.0",
    "@angular/core": "~9.0.0",
   
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "~9.0.0",
    "@angular/platform-browser-dynamic": "~9.0.0",
    
   
    "@ng-bootstrap/ng-bootstrap": "^6.0.0",
    "@ng-select/ng-select": "^3.7.2",
    "@nicky-lenaers/ngx-scroll-to": "^3.0.1",
    "@types/chartist": "^0.9.47",
    "angular-archwizard": "^5.0.0",
    "angular-google-charts": "^1.1.4",
    }

I have imported the {MatTabsModule} in my module.ts

import {MatTabsModule} from '@angular/material/tabs'

...
..
@NgModule({
declarations: [
...
..],
imports: [
 ....
MatTabsModule,
....]
..
..
export class PagesModule {}

Still when I use

<mat-tab-group></mat-tab-group>

I get the error mentioned in the top.

What am I doing wrong?

Anamik Adhikary
  • 401
  • 1
  • 8
  • 27

1 Answers1

1

You have not provided the name of your component and only a snippet of your PagesModule. Maybe your compoent is missing from your module-declarations.

Make sure to add your component to your declarations as well...

import {MatTabsModule} from '@angular/material/tabs'
import {MyComponentThatThrowsTheError} from '<path/to/your/component>/MyComponentThatThrowsTheError.component>'
...
..
@NgModule({
declarations: [
MyComponentThatThrowsTheError
..],
imports: [
 ....
MatTabsModule,
....]
..
..
export class PagesModule {}
Oma_Hilde
  • 11
  • 2