标签: angularfire2

使用“where()”时,在 AngularFirestore 中查询集合会导致没有数据

我有几个城镇的火力基地位置列表。该访问适用于:

 public locations: Observable<any[]>;
 constructor(db: AngularFirestore) {
 this.locations = db.collection('/Locations').valueChanges();}
Run Code Online (Sandbox Code Playgroud)

然后我可以通过以下方式访问所有位置的数据:

 {{ location.location_id }} etc
Run Code Online (Sandbox Code Playgroud)

现在我想在下一页中访问一个特定城镇的所有位置。

this.locationCollection = db.collection('/Locations', ref =>
ref.where('location_id', '==', 'Townname'));
Run Code Online (Sandbox Code Playgroud)

但它不可分配或_标量。如果我将 locationCollection 更改为 AngularFirestoreCollection 那么我不会得到任何错误,但也没有数据。如果我将类位置更改为接口,它也是一样的。我什至试图得到

this.location = db.doc('/Locations/' + townname);
Run Code Online (Sandbox Code Playgroud)

但我无法访问属性或将请求记录到控制台。我觉得我在太多过时的教程上浪费了时间。有人能指出我正确的方向吗?或者有人有带有最新 Firebase 设置的角度英雄示例吗?

javascript firebase angularfire2 angular google-cloud-firestore

3
推荐指数
1
解决办法
733
查看次数

在将 gmail 与 ionic 3 集成时遇到问题,出现运行时错误 &gt;&gt;Object(...) is not a function

我正在使用ionic 3 ,我试图通过firebasegoogle plus 登录集成到我的应用程序中。但我收到错误,

错误是>>

 ERROR TypeError: Object(...) is not a function
    at GooglePlus.login (index.js:27)
    at HomePage.webpackJsonp.186.HomePage.login (home.ts:28)
    at Object.eval [as handleEvent] (HomePage.html:3)
    at handleEvent (core.js:13589)
    at callWithDebugContext (core.js:15098)
    at Object.debugHandleEvent [as handleEvent] (core.js:14685)
    at dispatchEvent (core.js:10004)
    at core.js:10629
    at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
    at t.invokeTask (polyfills.js:3)


I am putting code below which I have used for integrationg google plus  Integration 
Run Code Online (Sandbox Code Playgroud)

.ts 文件

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from …
Run Code Online (Sandbox Code Playgroud)

ionic-framework ionic2 angularfire2 ionic3 angular

3
推荐指数
1
解决办法
1076
查看次数

我可以在 Firebase 身份验证中验证电子邮件的域区域吗?

我可以在 Firebase 身份验证中验证电子邮件域区域吗?

例如,我只想为来自 yahoo 和 gmail 的电子邮件 @yahoo.com、@gmail.com 电子邮件)提供成功注册

ps当然我可以在客户端验证它,但这还不够

javascript firebase firebase-authentication angularfire2

3
推荐指数
1
解决办法
889
查看次数

反转 AngularFire2 Angular 6 中的可观察数组

我正在使用 Observable 数组来获取实时数据。数据按升序排列,但我需要它以相反的顺序显示。互联网上的示例是 Angular 5 之前的,语法不再有效。请指教

html

  <tr *ngFor="let card of cards  | async;let last = last ">
              <td> <img [src]="card.frontImageUrl" width=200 height="100"></td>
</td>


refreshCards(){
    this.cards = this.dataSvc.fetchCards().pipe(
      map((cards: any) => cards.map(cardObj => new Card(cardObj.key, cardObj._frontImageUrl, cardObj._backImageUrl, cardObj._status, cardObj._date, cardObj._userId, cardObj._message)))
    );
  }
Run Code Online (Sandbox Code Playgroud)

调用firedb

fetchCards(){
    this.cardList = this.db.list<Card>('adminCardQueue', ref => ref.orderByChild('_date').limitToLast(50))

    return this.cardList.snapshotChanges().pipe(
       map(changes => 
        changes.map(c => ({ key: c.payload.key, ...c.payload.val()}))
       )
      ) ;
  }
Run Code Online (Sandbox Code Playgroud)

firebase firebase-realtime-database angularfire2

3
推荐指数
1
解决办法
1670
查看次数

firebase 电话身份验证“由于异常活动,我们已阻止来自此设备的所有请求。稍后重试。”

我正在开发和测试一个应用程序。当我期待使用 6 位数笔发送短信时,我收到以下消息。

{code: "auth/too-many-requests", message: "由于异常活动,我们已阻止来自此设备的所有请求。请稍后重试。"}

所以我尝试去authentication=> Sign-in method=>phone并添加 # 进行测试,但出现以下错误

添加测试电话号码时出错

有谁知道如何解决这些问题之一,以便我可以继续测试我的应用程序。

谢谢

firebase firebase-authentication angularfire2

3
推荐指数
1
解决办法
9269
查看次数

Firebase Firestore 不适用于 Angular Universal:package.json 不存在

我按照教程创建服务器端渲染的应用程序。之后我运行 npm install firebase @angular/fire --save 并像这样导入 AppModule 中的模块

import { AngularFireModule } from "@angular/fire";
import { AngularFirestoreModule } from "@angular/fire/firestore";
import { AngularFireStorageModule } from "@angular/fire/storage";

 AngularFireModule.initializeApp(environment.firebase),
 AngularFirestoreModule,
 AngularFireStorageModule,
Run Code Online (Sandbox Code Playgroud)

当我尝试使用 npm run build:ssr && npm run serve:ssr 为应用程序提供服务时发生错误。我得到的错误是

C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:159431
        throw new Error("package.json does not exist at " + package_json_path);
        ^
Error: package.json does not exist at C:\Users\user\Documents\prueba\PruebaApp\dist\package.json
    at Object.PsoT.exports.find (C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:159431:15)
    at Object.wPNL (C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:188373:12)
    at __webpack_require__ (C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:20:30)
    at Object.XpdW (C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:166719:12)
    at __webpack_require__ (C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:20:30)
    at Object.g1pB (C:\Users\user\Documents\prueba\PruebaApp\dist\server\main.js:175163:27)
    at __webpack_require__ …
Run Code Online (Sandbox Code Playgroud)

firebase angularfire2 angular-universal angular google-cloud-firestore

3
推荐指数
1
解决办法
2862
查看次数

部署到 Heroku 后,firebase 身份验证无法正常工作。仍然可以在 localhost:4200 的开发环境中工作

将我的 Angular 7 应用程序部署到 heroku 后;我的 Google 和 Facebook 的 Firebase 身份验证不再有效。两者都显示相同的错误消息(如下)。即使在隐身模式下,它们也会显示相同的错误消息(与下面的相同)。

我已在我的 firebase 授权域中将 myDomain.com 和 myDomain.herokuapp.com 列入白名单。我还将 myDomain.herokuapp.com 添加到我的 Google 开发控制台的授权域中。

glogin() {
    this.socialLogin(new auth.GoogleAuthProvider());
  }
fbLogin() {
        this.socialLogin(new auth.FacebookAuthProvider());
      }
socialLogin(provider) {
  this.afAuth.auth.signInWithRedirect(provider)
    .then((user) => {
      console.log('Sign in with google: ', user);
    }).catch(() => {
    // Todo - something went wrong
  });
  }
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

Uncaught (in promise): Error: Cannot match any routes. URL Segment: '__/auth/handler'
Error: Cannot match any routes. URL Segment: '__/auth/handler'
Run Code Online (Sandbox Code Playgroud)

Uncaught (in promise): …
Run Code Online (Sandbox Code Playgroud)

heroku node.js express firebase-authentication angularfire2

3
推荐指数
1
解决办法
2254
查看次数

firestore 检查 id 是否存在于 ids 数组中

我使用 firebase firestore 为我的网站开发一个简单的聊天应用程序。每个聊天会话都有一个 id

假设我有一个 id 数组

chat_sessions = ["q93XhadA9QQLu6X8yfZB", "YXEYISEI8b2iixCcP3VO", "GXrSZbtrmN5NcrtvjFYp"]

我想使用下面的代码获取 id 等于 chat_sessions 对象中任何 id 的所有文档。

return this.afs
    .collection('chats', ref => ref.where('uid','in_array',chat_sessions)).snapshotChanges...
Run Code Online (Sandbox Code Playgroud)

但我没有得到任何结果。

我来自 PHP/MYSQL 背景,PHP 相当于我想要实现的目标,在 PHP 中是这样的

if(in_array(uid,chat_sessions)){
      get(doc/uid)
      }
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我们进行正确的查询,根据数组中的 id 列表检查文档 id 吗?谢谢你!

javascript firebase angularfire2 google-cloud-firestore

3
推荐指数
2
解决办法
9556
查看次数

Firebase:...node_modules\firebase\app\dist\app\index 没有导出成员“用户”

在升级到 Angular 13 后,我刚刚将 Firebase+AngularFire 包从 7 升级到 9,调整了一些内容以使用@angular/fire/compat/*导入路径。

但我在几个地方使用了firebase.User,例如,基于 来初始化配置文件firebase.User

private createProfile(user: firebase.User | null): UserProfile | null {
    if (!user) {
      return null;
    }
    return {
      displayName: user.displayName ?? '',
      email: user.email ?? '',
      photoURL: user.photoURL ?? '',
      uid: user.uid,
      userIncomplete: !user.displayName || !user.email || !user.photoURL,
    };
  }
Run Code Online (Sandbox Code Playgroud)

但现在它找不到firebase.User

Error: src/app/auth/state/auth.service.ts:60:40 - error TS2694: Namespace '"/node_modules/firebase/app/dist/app/index"' has no exported member 'User'.

60   private createProfile(user: firebase.User | null): UserProfile | null …
Run Code Online (Sandbox Code Playgroud)

firebase angularfire firebase-authentication angularfire2 angular

3
推荐指数
1
解决办法
2556
查看次数

Firebase存储和angularfire2

如何使用角火2从Fire基地存储中获取图像2.非常感谢!

constructor(public af: AngularFire) {
this.items = af.database.list('/message');
this.picture = af.database.list('/profile');
}
Run Code Online (Sandbox Code Playgroud)

firebase firebase-storage angularfire2

2
推荐指数
1
解决办法
7041
查看次数