angularfire2

Firestore, how to combine more than 2 references to the collection at the same time

☆樱花仙子☆ 提交于 2020-01-16 19:01:10
问题 I use the method described in Firestore how to get the collection value from another collection document id is referenced but i've to combinate two reference document in one time but in other collections like: cash.models.ts: import { DocumentReference } from "@angular/fire/firestore"; export class Cash { // .collection('contactors') id: string; person: DocumentReference<Workers>; contactor: DocumentReference<Contactors>; nr_dokumentu: string; kwota: number; data: string; } export class

Get firebase database of current uid returns undefined

▼魔方 西西 提交于 2020-01-16 09:39:28
问题 I have a page to a retrieve user's information, but I am getting undefined. Below is my data structure { "posts" : { "-L4QKxs6d06Vq3amQ7C8" : { "content" : "Test", "owner" : "D5hkgRIN87OUr3rdSGK1Znws1aB2", "title" : "Admin Post" }, "-L4UDg1_glHcqwGjGpTQ" : { "content" : "fsdfd", "owner" : "D5hkgRIN87OUr3rdSGK1Znws1aB2", "title" : "rewsrwr" } }, "users" : { "D5hkgRIN87OUr3rdSGK1Znws1aB2" : { "posts" : { "-L4QKxs6d06Vq3amQ7C8" : { "title" : "Admin post" }, "-L4UDg1_glHcqwGjGpTQ" : { "title" :

Firebase paging data. Is it possible?

↘锁芯ラ 提交于 2020-01-16 09:08:17
问题 I have a function which basically reads data from firebase. I am trying to implement paging. Please see what i tried. I have seen other posts on this website but they are not very clear. getFormData(pageSize:number,pageIndex:number,af:AngulrFireDatabase) { Try1: Returning all records ---------------------------- return this.af.list('/forms').skip(pageIndex*pageSize).take(pageSize); Try2: Not sure how to use the previous page last key value to pass to load the next page data. -----------------

Angularfire2 attach more data to user collection

孤街浪徒 提交于 2020-01-15 11:18:19
问题 I am creating an app where users can create groups. group collection is stored inside each user, and if owner of the group ads members corresponding users id and role only saved inside group collection. So when owner visits group members i wish to show full info of users which is in another collection out side groups. these are two collections in my firestore database this.afs.collection(`users/${ownerId}/groups/${gid}/users`) this.afs.doc(`users/${ownerId}`) //full user data here is how i

Angularfire2 attach more data to user collection

浪子不回头ぞ 提交于 2020-01-15 11:18:07
问题 I am creating an app where users can create groups. group collection is stored inside each user, and if owner of the group ads members corresponding users id and role only saved inside group collection. So when owner visits group members i wish to show full info of users which is in another collection out side groups. these are two collections in my firestore database this.afs.collection(`users/${ownerId}/groups/${gid}/users`) this.afs.doc(`users/${ownerId}`) //full user data here is how i

canActivate doesn't respond upon subscription change Angular 2 Router AngularFire2

半城伤御伤魂 提交于 2020-01-15 03:44:26
问题 I'm using AngularFire2. This is how I approached my AuthGuard service: canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean { this.af.auth.subscribe((auth) => { if(auth == null) { this.router.navigate(['/login']); this.allowed = false; } else { this.allowed = true; } }) return this.allowed; } The above code works, except when I visit a guarded page directly (i enter URL in browser), it doesn't load the respective component after the subscription resolves to true. In

Has no exported member 'InjectionToken'

自闭症网瘾萝莉.ら 提交于 2020-01-15 03:33:12
问题 I am building an Angular2 app with firebase. The problem is that the entire application is working fine in Visual Studio Code but not in c9, even though my procedure of installing all the packages is the same. In c9 I am getting the error : ERROR in /home/ubuntu/workspace/map-report/node_modules/angularfire2/app/firebase.app.module.d.ts (1,10): Module '"/home/ubuntu/workspace/map-report/node_modules/@angular/core/index"' has no exported member 'InjectionToken'. ERROR in /home/ubuntu/workspace

How to map and reduce child values from FirebaseListObservable

一笑奈何 提交于 2020-01-14 12:18:41
问题 I am trying to sum up test scores, my data looks like this { testResult: { foo: {foo1: x}, {foo2: y} }, { bar: {bar1: z} 'foo' and 'bar' are meaningful subcategories of questions, child-nodes hold questionIDs and corresponding scores. I need to sum up scores ordered by categories. I query the list like this let res = this._dbref.database.list('/bmzi-answers',{ query: { orderByKey: true, equalTo: id } }) and displaying the result with {{ res | async | json }} shows me, that the query works. I

Mock AngularFireAuth When Unit Testing an Angular Service

吃可爱长大的小学妹 提交于 2020-01-13 18:12:46
问题 I have an authService which when instantiated subscribes to AngularFireAuth 's Observable authState and sets the services' internal (private) property authState . So I can unit test authService I highjack the services' internal authState with Reflect.get/set in my test specs so I can control its value. The problem is of course authService is still subscribing to AngularFireAuth 's Observable authState during its instantiation and I don't want, nor need it to. I presume I need to mock out

AngularFire2 - How to maintain logged in state after page refresh

随声附和 提交于 2020-01-12 09:54:30
问题 I'm using AngularFire2 for an app and I've gotten the registration/login functionality working with Firebase, however, every time I refresh the page, the logged in state is reset and won't persist. I can't quite find functionality to do this, though I feel I'm missing something very small. Can I use the AngularFireAuth to check on page load somewhere? Here is my auth provider code: import { Injectable } from '@angular/core'; import {Observable, Subject, BehaviorSubject} from "rxjs/Rx"; import