Reputation: 174696
ng test
shows the below error but it works as expected in reality.
Error: Template parse errors:
No provider for NgControl ("
<div class="form-group">
<label class="control-label">Location</label>
[ERROR ->]<select class="selectpicker" *ngIf="locations" data-style="btn btn-primary btn-round" title="Select A"): VehicleFormComponent@27:4
No provider for NgControl (" <div class="form-group label-floating">
<label class="control-label">Is Available</label>
[ERROR ->]<md-slide-toggle [(ngModel)]="isAvailable" color="primary" [ngModelOptions]="{standalone: true}">
"): VehicleFormComponent@41:4 in src/test.ts (line 25739)
Expected undefined to be truthy.
I think it's mainly because of adding [ngModelOptions]="{standalone: true}"
in a custom tag.
Upvotes: 4
Views: 19911
Reputation: 825
If anybody else comes here, maybe this will help. I was missing the optional decorator in the constructor:
constructor(@Optional() @Self() public ngControl: NgControl) {}
Upvotes: 3
Reputation: 5711
Did you add reference to "FormsModule" in your TestBed module?
import { FormsModule } from '@angular/forms';
TestBed.configureTestingModule({
imports: [ FormsModule ]
})
.compileComponents();
Upvotes: 19