error: Failed: Template parse errors: 'mat-checkbox' is not a known element
26,199
You need to add imports
array above declarations
like this :
Add it like this :
import { MatCheckboxModule } from '@angular/material/checkbox';
And add imports
array like this :
TestBed.configureTestingModule({
imports: [
MatCheckboxModule
],
declarations: [AddAlarmsFormComponent]
})
Author by
Admin
Updated on January 29, 2020Comments
-
Admin over 4 years
I create this code for testing my component.
I tried this code:
describe('Component: AddAlarms', () => { let component: AddAlarmsFormComponent; let fixture: ComponentFixture<AddAlarmsFormComponent>; beforeEach(() => { TestBed.configureTestingModule({ declarations: [AddAlarmsFormComponent] }); fixture = TestBed.createComponent(AddAlarmsFormComponent); component = fixture.componentInstance; }); });
when run
ng test
show this error:Failed: Template parse errors: 'mat-checkbox' is not a known element: 1. If 'mat-checkbox' is an Angular component, then verify that it is part of this module. 2. If 'mat-checkbox' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. (" </div> <div class="input-field col s2"> [ERROR ->]<mat-checkbox class="example-margin" (click)="sortbydate()">Dates</mat-checkbox> </div> "): ng:///DynamicTestModule/NotificationsComponent.html@12:10
I verify my module.ts and it's ok. So, I have this:
import {MatCheckboxModule} from '@angular/material/checkbox';
Can you tell me, what is the problem?
-
Admin almost 6 yearsI decided on both, even on the
module
and inspec.ts
But nothing happens -
Edgar Quintero about 5 yearsThe angular example code doesn't even have this, man their documentation is really sub par.