我需要我无法弄清楚的这种奇怪状况的帮助,我一直在获取“用户”类型上不存在属性“密码”。即使,我在user.ts类上将密码声明为字符串
user.ts
export interface User{
email: string;
password: string;
}
我的注册页面
<ion-content padding>
<ion-item>
<ion-label floating>Email</ion-label>
<ion-input type="text" [(ngModel)]="user.email"></ion-input>
</ion-item>
<ion-item>
<ion-label floating>Password</ion-label>
<ion-input type="password" [(ngModel)]="user.password"></ion-input>
</ion-item>
<button ion-button block (click)="register(user)">Cadastrar</button>
我的register.ts
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams} from 'ionic-angular';
import { User } from 'firebase/app';
import { AngularFireAuth } from "angularfire2/auth";
@IonicPage()
@Component({
selector: 'page-cadastro',
templateUrl: 'cadastro.html',
})
export class CadastroPage {
user = {} as User;
constructor(
public navCtrl: NavController, public navParams: NavParams,
private afAuth: AngularFireAuth
) {
}
ionViewDidLoad() {
console.log('ionViewDidLoad CadastroPage');
}
async register(user: User){
try{
const result = await this.afAuth.auth.createUserWithEmailAndPassword(user.email, user.password);
console.log(result);
}
catch(e){
console.error(e);
}
}
}