i am using Angular 2+ forms.
Error in details : Uncaught Error: Template parse errors: There is no directive with "exportAs" set to "ngModel" ("-group"> First Name ]#firstName = "ngModel" (change) ="log(firstName)" id="firstName" class="form-control"> ) at JitCompiler._compileComponents (compiler.js:25895) at compiler.js:25808 at Object.then (compiler.js:2166) at JitCompiler._compileModuleAndComponents (compiler.js:25807)
Below is my contact-form.component.html page :
<form>
<div class="form-group">
<label for="firstName">First Name</label>
<input required ngModel name="firstName" #firstName = "ngModel" (change) ="log(firstName)" id="firstName" class="form-control">
<div class="alert alert-danger" *ngIf = "!firstName.valid">First Name is required</div>
</div>
<div class="form-group">
<label for="comment">Comment</label>
<textarea ngModel name ="comment" id="comment" cols="30" rows="10" class="form-control"></textarea>
</div>
<button class="btn btn-primary">Submit</button>
</form>
below is my contact-form.component.ts page :
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'contact-form',
templateUrl: './contact-form.component.html',
styleUrls: ['./contact-form.component.css']
})
export class ContactFormComponent {
log(x) {
console.log(x);
}
}
app.module.ts
or the module you have defined – Anton