angularfire2

How to return an observable from service in angular after chaining pipe operations

▼魔方 西西 提交于 2021-01-29 05:55:50
问题 I'm trying to chain / pipe operations and return an Observable from a Service in angular which uses angular fire. With promises I have this working Service saveDiploma(diploma: { title: any; description: any; picture: any }) { return new Observable(observer => { const id = this.db.createId(); this.storage.ref(`diplomas/${id}/original.jpg`) .putString(diploma.picture, 'data_url') .then(task => { task.ref.getDownloadURL() .then(url => { const saved = { title: diploma.title, description: diploma

Why this Angular applications can't handle the user status (logged in\out) changing the displayed content after that the user logged in?

故事扮演 提交于 2021-01-27 16:27:35
问题 I am working on an Angular application using AngularUI (the Angular bundle, this one: https://www.npmjs.com/package/firebaseui-angular) to handle user registration\login on Firebase My application also uses AnularFire 2 and I have the following problem trying to handle the user status (if the user is logged in or logged out). This is my home component TypeScript code: import { Component, NgZone, OnInit } from '@angular/core'; import { AngularFireAuth } from '@angular/fire/auth'; import {

Angular 11 run on SSR @nguniversal/express-engine ReferenceError: globalThis is not defined

淺唱寂寞╮ 提交于 2021-01-27 07:22:38
问题 Trying to run @angular/fire on Angular 11 and @nguniversal/express-engine (SSR). When init AngularFireModule in app.module.ts there are error when running command npm run dev:ssr or npm run serve:ssr it is ok when ng serve . Same problem with angular 10 version. Does any one have any clue what to do ? app.module.ts: @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule.withServerTransition({ appId: 'serverApp' }), AppRoutingModule, ServiceWorkerModule.register('ngsw-worker.js',

Firestore: Query collection using “where” and only retrieve document IDs

爷,独闯天下 提交于 2021-01-27 04:12:07
问题 I want to query a firestore documents collection and want only retrieve the document ids with angularfire2, to save costs for reading all documents . As far as I understand it, the following code is retrieving all documents too and is causing read ops on all documents, no matter if I use doc.data() or not. Am I right? db.collection("cities").where("capital", "==", true).onSnapshot(function(querySnapshot) { querySnapshot.forEach(function(doc) { console.log(doc.id); } }); So in the

Firestore: Query collection using “where” and only retrieve document IDs

泄露秘密 提交于 2021-01-27 04:11:35
问题 I want to query a firestore documents collection and want only retrieve the document ids with angularfire2, to save costs for reading all documents . As far as I understand it, the following code is retrieving all documents too and is causing read ops on all documents, no matter if I use doc.data() or not. Am I right? db.collection("cities").where("capital", "==", true).onSnapshot(function(querySnapshot) { querySnapshot.forEach(function(doc) { console.log(doc.id); } }); So in the

Update the email verification status without reloading page

五迷三道 提交于 2021-01-13 09:13:54
问题 After registering in my web app, i redirect the user to a page, where he is told to verify his email. Once he has done that, i want to automatically detect the change of the verificationStatus and then change the page. Something along those lines. auth.user.subscribe(user => { if (!!user && user.emailVerified === true) { this.redirectToLogin(); } }); I couldn't find any way to detect changes of the emailVerified status, so I thought, maybe have an interval runnning that is updating the user

Update a map field in all documents in Firestore

主宰稳场 提交于 2021-01-05 05:42:45
问题 I'm doing a web application in Angular 6 and the library angularfire2. I have two collections, teams and users . If a team's name is changed, the team's name must also be changed inside of the user's document. export interface User { firstName: string; emailAddress: string; team: TeamId; } export interface UserId extends User { id: string; } export interface Team { name: string; abbreviation?: string; } export interface TeamId extends Team { id: string; } Class: const team: Team = { name:

How to provide/mock Angularfirestore module inside angular component for default test to pass?

青春壹個敷衍的年華 提交于 2020-12-30 07:35:17
问题 How can I provide AngularFirestore module inside my app.component so that my default toBeTruthy() test will pass? Error: StaticInjectorError(DynamicTestModule)[AppComponent -> AngularFirestore]: StaticInjectorError(Platform: core)[AppComponent -> AngularFirestore]: NullInjectorError: No provider for AngularFirestore! app.component export class AppComponent implements OnInit { private notesCollection: AngularFirestoreCollection<any>; public notes: Observable<any[]>; constructor(private afs:

How to provide/mock Angularfirestore module inside angular component for default test to pass?

匆匆过客 提交于 2020-12-30 07:32:56
问题 How can I provide AngularFirestore module inside my app.component so that my default toBeTruthy() test will pass? Error: StaticInjectorError(DynamicTestModule)[AppComponent -> AngularFirestore]: StaticInjectorError(Platform: core)[AppComponent -> AngularFirestore]: NullInjectorError: No provider for AngularFirestore! app.component export class AppComponent implements OnInit { private notesCollection: AngularFirestoreCollection<any>; public notes: Observable<any[]>; constructor(private afs:

How do I make a query based on the return of another query in Angular with Firestore?

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-15 05:49:27
问题 Im trying to get some Ids from a collection, and then trying to use each of these Ids to get more data from another collection. Here is what I got done so far: Basically, I have blog app in which multiple users will be able to post an article. And said article has categories. The thing is, when a user selects a category to filter, it will bring me all USERS that have an article in said category (instead of bringing all articles of the selected category). So, in Firestore I have: categories/