I am getting this error - "Template parse errors: No provider for NgControl"
The error comes from this line of code --> <select (ngModel)="currencies" (ngModelChange)="showPurchase($event)" class="annka-center" name="curencies"> <option *ngFor="let money of currencies; let i = index" (ngValue)="money" (click)="showPurchase(money)"> {{money.Currency}} </option> </select>
The above code worked smoothly till i added ReactiveFormsModule to my app.
I tried the solution here
ERROR in : No provider for NgControl Angular AOT
but that didnt work for me. I am using Angular 4.
The problem seems to be with the Angular Elements where when we create angular element we have to pass the component to entryComponents and that leads to angular compiles it factory even that it's not on the template, and because it's not part of any form and doesn't have any From directive on it -> which gives the error No Provider For NgControl
To fix NullInjectorError: No provider for HttpClient! error in Angular follow the below steps. Open app.module.ts file of Angular Application. Import HttpClientModule from @angular/common/http. Add HttpClientModule to the @NgModule imports array.
There are two types of form approaches in Angular. Creating a form using FormControl, FormGroup, and FormArray are said to be reactive forms. Therefore, they use the ng module as ReactiveFormsModule. FormControl is the class used to get and set values and validation of the form control such as <input> and <select> tag.
It can be used standalone as well as with a parent form. There are two types of form approaches in Angular. Creating a form using FormControl, FormGroup, and FormArray are said to be reactive forms. Therefore, they use the ng module as ReactiveFormsModule.
Should be
<select [(ngModel)]="currencies" (ngModelChange)="showPurchase($event)" class="annka-center" name="curencies"> <option *ngFor="let money of currencies; let i = index" (ngValue)="money" (click)="showPurchase(money)"> {{money.Currency}} </option> </select>
Also make sure you import FormsModule
inside the app.module.ts
under imports
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; @NgModule({ imports: [ FormsModule ReactiveFormsModule ]
I too got this error because I forgot to add the formControlName
directive to my form control in the template, by which I mean:
<input formControlName="firstName" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With