jeudi 28 septembre 2017

Failed: Template parse errors: Angular 2

I'm getting the following error once running Unit-test angular CLI. The following error is on a form.

Failed: Template parse errors:
There is no directive with "exportAs" set to "ngForm" ("<form [ERROR ->]#userForm = "ngForm" (ngSubmit)="onSubmit(userForm.value)">
    <div class="form-group">
        <label for="e")

The html form

<form #userForm = "ngForm" (ngSubmit)="onSubmit(userForm.value)">
<div class="form-group">
        <label for="exampleInputCountry">Country</label>
        <input class="form-control" id="country" placeholder="Country" ng name="country" ngModel>
    </div>
    <button type="submit" class="btn btn-primary">Submit</button>
</form>

app.module.ts

@NgModule({
  declarations: [
  AppComponent,
  [...]
  ],
  imports: [
  FormsModule,
  [...] 
  ],
  providers: [],
  bootstrap: [AppComponent]
})

Aucun commentaire:

Enregistrer un commentaire