控制台给出了以下错误:
我已经尝试过在Google上找到的多种解决方案,但它仍然无效。
import { Component, OnInit } from '@angular/core';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';
import { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import * as firebase from 'firebase/app';
@Component({
selector: 'app-signup',
templateUrl: './signup.component.html'
})
export class SignupComponent implements OnInit {
constructor() { }
signUp(email: string, password: string){
firebase.auth().createUserWithEmailAndPassword(email, password)
.catch(function(error:any) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
});
}
ngOnInit() {
}
}
我该如何解决这个问题?
答案 0 :(得分:1)
Javascript类型可能有问题。 Firebase Auth要求参数类型为string
。 Observables,String Object和其他类似字符串的对象实际上不是string
的类型。
typeof new String("email@email.io") // "object"
typeof String(new String("email@email.io")) // "string"
typeof "email@email.io" // "string"
您可以尝试这样的事情:
firebase.auth().createUserWithEmailAndPassword(String(email), String(password))