没有找到带有 exportAs 'ngModel' 的指令

时间:2021-01-29 05:30:51

标签: angular forms

在我的 Angular 应用程序中,我有如下的 registration.component.html。

<form [formGroup]="formGroup" (ngSubmit)="registrationProcess()">
<div class="form-group">
  <label for="email">Email:</label>
  <input type="email" class="form-control" placeholder="Enter email"   formControlName="email"  #email="ngModel" >
  <small [class.d.none]="email.invalid && email.touched"></small>

</div>
<div class="form-group">
  <label for="pwd">Full Name :</label>
  <input type="name" class="form-control"  placeholder="Enter full name"   formControlName="fullname">
</div>

<div class="form-group">
    <label for="pwd">Password:</label>
    <input type="password" class="form-control" placeholder="Enter password"  formControlName="password1">
  </div>

  <div class="form-group">
    <label for="pwd">Confirm Password:</label>
    <input type="password" class="form-control"   placeholder="Enter confirm password"  formControlName="password2">
  </div>

<button type="submit" class="btn btn-info">Submit</button>
<button  style="background-color: rgb(59, 17, 99); margin-left: 80px;"  class="btn btn-info" (click)="goToLogin()">Login</button>

这是来自我的 app.module.ts

imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
NavigationModule,
HttpClientModule,
FormsModule,
ReactiveFormsModule
 ],

但它给了我以下错误。

<块引用>

未找到带有 exportAs 'ngModel' 的指令

谁能帮我解决这个问题。

1 个答案:

答案 0 :(得分:0)

仅使用 #email 而不是 #email="ngModel"