0
我已将Firebase用于authenticaton目的。如何从一个服务中抛出错误并将其捕获到Angular2的另一个组件中
这是验证
export class AuthService {
signupUser(email:string,password:string){
firebase.auth().createUserWithEmailAndPassword(email,password).catch((error)=>{
console.log(error);
})
}
代码这是signup.Component.ts
onSignup(form:NgForm){
const email=form.value.email;
const password=form.value.password;
this.authService.signupUser(email,password);
}
因此,而不是印刷错误代码注册,我想抛出一个错误,在注册组件中捕获它,以便我可以使用该错误并向用户显示一条Flash消息。我怎样才能做到这一点?有人可以解决我的问题吗?