Html AngularFire登录验证错误

Html AngularFire登录验证错误,html,angular,typescript,login,angularfire,Html,Angular,Typescript,Login,Angularfire,我正在尝试为我们网站上的用户设置登录。用户可以注册,数据库收集他们的电子邮件和密码,但我无法验证登录电子邮件或密码。更多详情如下 以下是登录组件: import { Component, OnInit } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { Store } from '@ngrx/store'; import * as fromA

我正在尝试为我们网站上的用户设置登录。用户可以注册,数据库收集他们的电子邮件和密码,但我无法验证登录电子邮件或密码。更多详情如下

以下是登录组件:

import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';

import { Store } from '@ngrx/store';

import * as fromApp from '../../../reducers';

import * as app from '../../../core/store/app.actions';

import { AngularFireDatabase } from 'angularfire2/database';
import { AngularFireAuth } from 'angularfire2/auth';
import * as firebase from 'firebase/app';

@Component({
  selector: 'app-client-login',
  templateUrl: './client-login.component.html',
  styleUrls: ['./client-login.component.css']
})
export class ClientLoginComponent {

  client: FormGroup;

    constructor(
      private _fb: FormBuilder,
      private _afAuth: AngularFireAuth,
      private _afDb: AngularFireDatabase,
      private _appStore: Store<fromApp.State>

    ) {
      this.buildForm();

      // this._appStore.dispatch(new app.DisplayLoading());
    }

    ngOnInit() {}

    buildForm(): void {
      this.client = this._fb.group({
        email: ['', [Validators.required, Validators.email]],
        password: ['',Validators.required],
      });
    }

    login(email: string, password: string) {
      return this._afAuth.auth.signInWithEmailAndPassword(email, 
      password)
    }

}
如果你需要更多信息,请告诉我。如果您想在我们的GitHub目录中查看该项目,请点击此链接


我们一直在寻求帮助

问题是您的事件处理程序(即,
login()
)没有指定参数,但
login
要求将电子邮件和密码作为参数传入。在这种情况下,电子邮件和密码作为
undefined
传递给
signInWithEmailAndPassword()
,从而导致您观察到的运行时错误

要解决此问题,您可以更新模板以传入电子邮件和密码值:

<button (click)="login(client.get('email').value, client.get('password').value)" class="btn btn-primary" type="submit">Login</button>

(单击)=“login()”
-…你忘了什么吗?在尝试与API集成之前,编写一些单元测试并通过测试,这将使任何问题都更加明显。谢谢。我现在明白它是如何工作得更好了。在飞行中学习大部分内容。@HenryTobolka没问题:)
 {code: "auth/argument-error", message: "signInWithEmailAndPassword failed: First argument "email" must be a valid string.", ngDebugContext: DebugContext_, ngErrorLogger: ƒ}
<button (click)="login(client.get('email').value, client.get('password').value)" class="btn btn-primary" type="submit">Login</button>
login() {
  const email = this.client.get('email').value;
  const password = this.client.get('password').value;
  return this._afAuth.auth.signInWithEmailAndPassword(email, password);
}