Angular AbstractControl类型的参数不能分配给string类型的参数

Angular AbstractControl类型的参数不能分配给string类型的参数,angular,ionic3,Angular,Ionic3,我构建了一个表单,在这里我实现了一个表单验证,当用户将电子邮件或密码字段留空时,它只会显示一条错误消息。它工作得很好,但我的问题是,我将电子邮件和密码设置为“AbstractControl”,而不是“String”,因此当我尝试使用firebase对它们进行身份验证时,我会收到这样一条错误消息:“AbstractControl类型的参数不可分配给String类型的参数”。我认为问题在于我将电子邮件和密码设置为抽象控件,而不是将其设置为字符串。我如何覆盖它并允许验证和身份验证?这是我的密码 HTM

我构建了一个表单,在这里我实现了一个表单验证,当用户将电子邮件或密码字段留空时,它只会显示一条错误消息。它工作得很好,但我的问题是,我将电子邮件和密码设置为“AbstractControl”,而不是“String”,因此当我尝试使用firebase对它们进行身份验证时,我会收到这样一条错误消息:“AbstractControl类型的参数不可分配给String类型的参数”。我认为问题在于我将电子邮件和密码设置为抽象控件,而不是将其设置为字符串。我如何覆盖它并允许验证和身份验证?这是我的密码

HTML

<ion-content padding>
    <form [formGroup]="formgroup">
        <ion-list>
          <ion-item>
             <ion-label>Email</ion-label>
             <ion-input type="text" formControlName="email" name="email"></ion-input>
          </ion-item>
          <ion-item *ngIf="email.hasError('required') && email.touched">
            <p>*Email is required</p>
          </ion-item>

          <ion-item>
              <ion-label>Password</ion-label>
              <ion-input type="password" name="password" formControlName="password"></ion-input>
           </ion-item>
           <ion-item *ngIf="password.hasError('required') && password.touched">
             <p>*password is required</p>
           </ion-item>
        </ion-list>
      <button clear ion-button (click)="login()">Submit</button>
      </form>
</ion-content>

嗯,错误信息说明了一切。该错误是因为
使用Email和Password登录
需要
字符串
s,但您使用
AbstractControl
s调用了它

您可以使用
value
属性获取
AbstractControl
的值

将您的
登录方法更改为:

login() {
  this.aAuth.auth.signInWithEmailAndPassword(this.email.value, this.password.value)
    .then(e => console.log(e))
}
快速提示:

不确定您为什么在组件上创建
电子邮件
密码
属性,当您可以使用
this.formgroup.value
轻松获取表单的值时,您还可以使用destructuring从表单值中提取
电子邮件
密码
,然后将其传递给
signInWithEmailAndPassword
方法:

login() {
  const { email, passowrd } = this.formgroup.value;
  this.aAuth.auth.signInWithEmailAndPassword(email, password)
    .then(e => console.log(e))
}
login() {
  const { email, passowrd } = this.formgroup.value;
  this.aAuth.auth.signInWithEmailAndPassword(email, password)
    .then(e => console.log(e))
}