[Fixed] Getting No provider for NgControl Error after adding ReactiveFormsModule to my angular 4 app

Issue

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.

Solution

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      
        ]

Leave a Reply

(*) Required, Your email will not be published