如何使用 firebase 在 ionic 中创建用户配置文件

哈里斯·本·扎希德

我是 Ionic 和 Angular 的新手。我正在开发一个订单放置应用程序,但在创建新用户配置文件时遇到了问题。

我正在关注此视频,但数据未保存在 Firebase 中。另外,我已经在 firebase 中有一个带有名称顺序的列表。

配置文件

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Profiles } from "../../models/profile/profile";
import { AngularFireAuth } from 'angularfire2/auth';
import { AngularFireDatabase } from 'angularfire2/database';
import { LoginPage } from '../login/login';


@IonicPage()
@Component({
  selector: 'page-profile',
  templateUrl: 'profile.html',
})
export class ProfilePage {

  profile = {} as Profiles
  // ref:any;

  constructor(private afAuth: AngularFireAuth, private afDatabase: AngularFireDatabase, public navCtrl: NavController, public navParams: NavParams) {
    // this.ref = afDatabase.list("Profile");
  }

  createProfile(){
    const user = this.afAuth.authState.take(1).subscribe(auth => {
      this.afDatabase.object(`Profiles/${auth.uid}`).set(this.profile)
      .then(() => {
        // this.navCtrl.setRoot(LoginPage)

      });
      console.log(user);
    })
   }
}

模型/配置文件/配置文件.ts

export interface Profiles {
    firstName: string;
    lastName: string;
    eventName: string;
    hall: string;
    booth: string;

}

个人资料.html

<ion-header>
  <ion-navbar color="primary">
    <ion-title> Create Profile</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <ion-list>
    <ion-item>
      <ion-label floating [(ngModel)]="profile.firstName" ngDefaultControl>First Name</ion-label>
      <ion-input type="text"></ion-input>
    </ion-item>
    <ion-item>
      <ion-label floating [(ngModel)]="profile.lastName" ngDefaultControl>Last Name</ion-label>
      <ion-input type="text"></ion-input>
    </ion-item>
    <ion-item>
      <ion-label floating [(ngModel)]="profile.eventName" ngDefaultControl>Event Name</ion-label>
      <ion-input type="text"></ion-input>
    </ion-item>
    <ion-item>
      <ion-label floating [(ngModel)]="profile.hall" ngDefaultControl>Hall #</ion-label>
      <ion-input type="text"></ion-input>
    </ion-item>
    <ion-item>
      <ion-label floating [(ngModel)]="profile.booth" ngDefaultControl>Booth #</ion-label>
      <ion-input type="text"></ion-input>
    </ion-item>
  </ion-list>
  <button ion-button block (click)="createProfile(Profiles)">Create Profile</button>
</ion-content>

这是我在提交后进入控制台的内容

最后还有一件事,我还将 firebase 登录系统与我的应用程序集成在一起,它没有注销,所以不确定它是否会产生问题。

请指导我哪里做错了?

杰夫明成金

显然,您的双向数据绑定工作不正常。这就是为什么profile给你一个空的结果。

将所有[(ngModel)]指令重新定位到 中ion-input,而不是中ion-label

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法使用 Angular [Ionic] 检查 Firebase 中是否存在配置文件

如何使用Firebase安全规则创建公共/私人用户配置文件?

如何使用ionic和firebase获取注册用户的uid

如何配置Ionic 3 Firebase Analytics

Ionic 3 + Firebase Storage获取配置文件图像

如何在Linux中的所有用户中仅grep用户创建的配置文件?

如何使用信号基于Django中的用户属性创建特定的配置文件

在Django中创建新用户后,如何自动创建新配置文件?

在新的Firebase中,如何在xcode中使用多个配置文件?

连接时更新 firebase 中的用户配置文件

如何使用Ionic 4从Firebase获得价值

如何在登录Android时更新Firebase用户配置文件?

如何使用golang在Firebase中创建用户?

ionic,firebase:如何从firebase身份验证中获取所有用户电子邮件

如何在 Django REST API 中创建用户配置文件对象?

如何为数据库中的登录用户创建配置文件?

“ ionic run ios”如何添加配置文件

使用Angular2 / Ionic2删除Firebase用户

使用 Angular4 和 Angularfire2 (v4) 在 Firebase 中获取用户身份验证配置文件信息

如何在HTML(Ionic / Firebase / Angular)中显示TypeScript对象

如何在Ionic 4中使用cordova firebase.dynamiclinks插件?

如何使用Ionic 4删除Firebase Cloud Firestore中的元素数组

使用firebase在ionic 2中实现like/unlike函数

如何在用户模型中创建和包含配置文件(用户由其模型设计)?

如何使用React更新Firebase中电子邮件/密码帐户的电话号码的配置文件

如何在 React Native 中更新配置文件(displayName)firebase?

如何在VBA中查找用户配置文件的路径

Git不使用全局配置文件中的用户

颤振 Firebase用户身份验证和配置文件创建