I have just performed an Angular update and have been receiving the following error messages regarding angular material since then:
Error occurs in the template of component LanguageChangeComponent. src /app/common/language-change/language-change.component.html: 9: 9 - error NG8001: 'mat-radio-button' is not a known element:
- If 'mat-radio-button' is an Angular component, then verify that it is part of this module.
- If 'mat-radio-button' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
I think the module has been imported correctly, but the error message does not go away. What am I doing wrong?
The component looks like this (template):
<my-sidebar class="language-selection">
<div class="header">
<span>{{ cfg.title }}</span>
</div>
<div class="language-selection-radio-buttons">
<section>
<mat-radio-group [(ngModel)]="languageSelection">
<mat-radio-button value="en" [checked]="languageSelection === 'en'">Englisch</mat-radio-button>
<mat-radio-button value="de" [checked]="languageSelection === 'de'">Deutsch</mat-radio-button>
</mat-radio-group>
</section>
</div>
<div class="buttons">
<button class="button-primary" (click)="changeDefaultLanguage()">change</button>
</div>
</my-sidebar>
The associated module like this:
import { CommonModule } from '@angular/common';
import { LanguageChangeComponent } from './language-change.component';
import { MySideBarModule } from '@my-sidebar/core';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { MatRadioModule } from '@angular/material/radio';
@NgModule({
imports: [
CommonModule,
MySideBarModule,
MatRadioModule,
FormsModule,
TranslateModule
],
declarations: [
LanguageChangeComponent
],
exports: [
LanguageChangeComponent
]
})
export class LanguageChangeModule { }
Here is an excerpt from my package.json:
"dependencies": {
"@angular/animations": "^9.1.12",
"@angular/cdk": "^9.2.4",
"@angular/common": "~9.1.12",
"@angular/compiler": "~9.1.12",
"@angular/core": "~9.1.12",
"@angular/flex-layout": "^9.0.0-beta.31",
"@angular/forms": "~9.1.12",
"@angular/material": "^9.2.4",
"@angular/platform-browser": "~9.1.12",
"@angular/platform-browser-dynamic": "~9.1.12",
"@angular/router": "~9.1.12",
"@auth0/angular-jwt": "^5.0.1",
"@azure/msal-angular": "^1.0.0",
"@juggle/resize-observer": "^3.2.0",
"@microsoft/signalr": "^3.1.8",
"@ngx-translate/core": "^12.1.2",
"@ngx-translate/http-loader": "^4.0.0",
"angular-gridster2": "^8.3.0",
"angular-resize-event": "^1.2.1",
"azure-maps-control": "^2.0.26",
"classlist.js": "^1.1.20150312",
"lodash": "^4.17.15",
"moment": "^2.29.0",
"msal": "^1.3.2",
"ng-dynamic-component": "^5.0.6",
"ngx-json-viewer": "^2.4.0",
"ngx-simple-modal": "^1.4.11",
"rxjs": "~6.5.2",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.12",
"@angular/cli": "~9.1.12",
"@angular/compiler-cli": "~9.1.12",
"@angularclass/hmr": "^2.1.3",
"@compodoc/compodoc": "^1.1.9",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/lodash": "^4.14.155",
"@types/node": "^12.11.1",
"@types/webpack-env": "^1.14.0",
"codelyzer": "^5.1.2",
"cpx": "^1.5.0",
"jasmine-core": "~3.5.0",
"jasmine-reporters": "^2.3.2",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-cli": "~2.0.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~3.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"karma-junit-reporter": "^1.2.0",
"protractor": "~7.0.0",
"protractor-console-plugin": "^0.1.1",
"puppeteer": "^1.17.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~3.8.3"
}
Had the same issue, so I stopped the project, re-ran
npm i
, and was able to importMatRadioModule
into app-modules.ts.