首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有角度的防火墙:创建用户失败

具有角度的防火墙:创建用户失败
EN

Stack Overflow用户
提问于 2018-05-07 00:27:49
回答 1查看 779关注 0票数 0

最近:

角度: 5.2

Firebase SDK: 4.13.0

国家预防机制: 6.0.0

节点: v8.11.1

试图使用以下代码创建具有防火墙的用户注册:

signup.component.html:

代码语言:javascript
复制
    <form (ngSubmit)="onSignup(form)" #form="ngForm">
      <div class="form-group">
        <label for="email">Email</label>
        <input name="email" id="email" type="email" class="form-control" ngModel>
      </div>
      <div class="form-group">
        <label for="Password">Password</label>
        <input name="Password" id="Password" type="text" class="form-control"   ngModel>
      </div>
      <button type="submit" class="btn btn-success">Sign Up</button>
    </form>

signup.component.ts:

代码语言:javascript
复制
import { Component, OnInit } from '@angular/core';
import {NgForm} from '@angular/forms';
import {AuthService} from '../auth.service';

@Component({
  selector: 'app-signup',
  templateUrl: './signup.component.html',
  styleUrls: ['./signup.component.css']
})
export class SignupComponent implements OnInit {
  constructor(private authService: AuthService) { } 

  ngOnInit() {
  }

  onSignup(form: NgForm) {
    const email = form.value.email;
    const password = form.value.password;
    this.authService.signupUser(email, password);
  }

}

在AuthService.service.ts中:

代码语言:javascript
复制
import * as firebase from 'firebase';
import {Injectable} from '@angular/core';
import {Router} from '@angular/router';

@Injectable()
export class AuthService{
token: string;

constructor(private router: Router) {}

  signupUser(email: string, password: string) {
    firebase.auth().createUserWithEmailAndPassword(email, password)
      .catch(
        error => console.log(error) 
      );
  }}

但是,当我单击“注册”按钮时,它仍然会在控制台上抛出此错误:

代码语言:javascript
复制
ERROR 
N {code: "auth/argument-error", message: "createUserWithEmailAndPassword failed: Second argument "password" must be a valid string.", ngDebugContext: DebugContext_, ngErrorLogger: ƒ}
code:
"auth/argument-error"
message:
"createUserWithEmailAndPassword failed: Second argument "password" must be a valid string."

那么,是否有可能使用此方法使用firebase创建一个新用户?!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-07 04:40:36

SDK是正确的,看起来您的HTML中有一个错误。

<input name="Password" id="Password" type="text" class="form-control" ngModel>

idname都是大写属性Password,但在signupUser函数中,您正在尝试访问小写属性password

尝试将HTML更新为<input name="password" id="password" type="text" class="form-control" ngModel>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50205711

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档