Cannot read property 'error' of undefined in Angular 2?
During use of following code, I have code following error ,I think I have to import some proerty like FormModule in module.ts, but I don't not what is that?? Please help me to solve this?
Firstname: <input type="text" class="_firstname" name="txtFirstname" [(ngModel)]="firstName" placeholder="Enter First Name" #txtFather="ngModel"><br><br>
<div *ngIf="txtFirstname.error &&(txtFirstname.dirty || txtFirstname.touched)" class="alert alert-danger">
<div [hidden]="!txtFirstname.errors.required">
Name is required!
</div>
</div>
I've got:
reg.component.html:8 ERROR TypeError: Cannot read property 'error' of undefined
at Object.eval [as updateDirectives] (reg.component.html:9)
at Object.debugUpdateDirectives [as updateDirectives] (services.ts:443)
at checkAndUpdateView (view.ts:359)
at callViewAction (view.ts:767)
at execComponentViewsAction (view.ts:700)
at checkAndUpdateView (view.ts:413)
at callViewAction (view.ts:767)
at execComponentViewsAction (view.ts:700)
at checkAndUpdateView (view.ts:413)
at callWithDebugContext (services.ts:815)
#txtFather="ngModel"