angularfire2

Observable.forkJoin() doesn't execute

我的未来我决定 提交于 2019-11-30 01:02:10
问题 I have the following code: //Loop: For each user ID/Role ID, get the data userMeta.forEach((businessRole) => { Observable.forkJoin( af.database.object('/roles/'+businessRole.$value), af.database.object('/users/'+businessRole.$key) ).subscribe( data => { console.log("Data received"); data[1].role = data[0]; this.users.push(data[1]); }, err => console.error(err) ); I am trying to subscribe to a result of 2 observables using forkJoin . For some reasons, the "Data received" message is not shown.

Property 'pipe' does not exist on type 'AngularFireObject<{}>'

眉间皱痕 提交于 2019-11-30 00:02:46
问题 I'm a beginner to Angular. I'm watching the tutorial of Mosh Hamedani using the Angular version 6 but the problem is the tutorial version is 4. I'm working on the e-commerce project on AddToCart button where the product should increase it's quantity by clicking the button and updated in Firebase using productId and also if I try to add new product then id of that new product should add in AngularFire Database. Everything is working perfectly now I'm getting error in shopping-cart.service.ts

How to include the document id in Firestore collection in Angular 5

不问归期 提交于 2019-11-29 22:13:20
问题 I have this function that gets all the posts and I want to get the id of the post any idea how to get the id of the post or How to include the id when I add the document to the collection get_the_posts(){ this.Post_collection = this.afs.collection('posts'); return this.Posts = this.Post_collection.valueChanges(); } That gives me this output: [ { name: 'post 1 name' description: 'post description'}, { name: 'post 2 name' description: 'post description'}, { name: 'post 3 name' description:

'Joining' Firebase Queries in Angularfire2

廉价感情. 提交于 2019-11-29 20:40:25
问题 Update: The issues I was encountering with the empty value fields had to do with non-existent keys in my database, so most of the discourse here won't apply to your question. If you're looking for a way to 'join' queries in AngularFire2, the accepted answer below does a fine job of this. I'm currently using combineLatest instead of forkJoin . In order to do this you have to import 'rxjs/add/observable/combineLatest'; . I have the following denormalized Firebase structure: members -memberid1

Firestore: Add Custom Object to db

柔情痞子 提交于 2019-11-29 11:52:14
问题 Good Morning, I tried adding a new created object from this class: export class Sponsor implements ISponsor { title: string; description?: string; creation: ICreation; constructor(title: string, description: string, author: string) { this.title = title; this.description = description; this.creation = new Creation(author); } } and in my service, the create function looks like: createSponsor(sponsor) { sponsor.id = this.afs.createId(); return this.collection.doc(sponsor.id).set(sponsor); } When

Angular 2 Firebase Observable to promise doesn't return anything

◇◆丶佛笑我妖孽 提交于 2019-11-29 06:54:27
问题 I'm currently working on an Angular 2 project with AngularFire2 and I'm trying to convert a FirebaseListObservable to a Promise. I know that it doesn't make much sense since Observables are more useful but this function will be part of another function where multiple promises are chained. And I'm not familiar with how to subscribe to Observables within a chain of promises... The function gets executed in the service, however it seems to not return anything. Basically, what I want to do is

AngularFire2: Realtime Database: how to get key and value

Deadly 提交于 2019-11-29 02:12:02
I use AngularFire2 to get data from Firebase Database (realtime). What I have done: Firebase Database { “class” : { “student” : { “Tom” : “male”, “Mary” : “female”, “Peter” : “male”, “Laura” : “female” }, "numberOfStudent” : 10 } } app.component.ts import { AngularFireDatabase } from 'angularfire2/database'; import { Observable } from 'rxjs/Observable'; ... export class AppComponent { class: Observable<any>; students: Observable<any[]>; constructor(private db: AngularFireDatabase) { this.class = db.object(‘class’).valueChanges(); this.students = db.list(‘class/student’).snapshotChanges(); } }

Angular 2 AuthGuard + Firebase Auth

扶醉桌前 提交于 2019-11-28 18:47:21
I'm trying to build an AuthGuard for Angular 2 routes using Firebase Auth. This is the AuthGuard Service: import { Injectable } from '@angular/core'; import { CanActivate, Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { AuthService } from './auth.service'; @Injectable() export class AuthGuard implements CanActivate { constructor(private AuthService: AuthService, private router: Router) {} canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { if (this.AuthService.loggedIn) { return true; } this.router.navigate(['login']); return false; }

FirebaseList - Unable to access parse data fetched from firebase

ぃ、小莉子 提交于 2019-11-28 14:06:22
I'm getting " Error: InvalidPipeArgument: '[object Object]' for pipe 'AsyncPipe' " when running the following code. html template: <ion-list> <ion-item-sliding *ngFor="let item of shoppingItems | async"> <ion-item> {{ item.$value }} </ion-item> <ion-item-options side="right"> <button ion-button color="danger" icon-only (click)="removeItem(item.$key)"><ion-icon name="trash"></ion-icon></button> </ion-item-options> </ion-item-sliding> </ion-list> page ts: shoppingItems: AngularFireList<any>; constructor(public navCtrl: NavController, public firebaseProvider: FirebaseProvider) { this

How to get access to native Firebase object when using angularfire2?

放肆的年华 提交于 2019-11-28 11:01:22
I'm using AngularFire2 (2.0.0-beta.2) incombination with angular2 (2.0.0-rc.4). I'd like to get access to the native firebase object (not the AngularFire root object) from Angularfire2. Within my component, I want to make calls like: firebase.auth().currentUser.updateEmail("user@example.com") where firebase is the native firebase object, like that you get from the fragment below: <script src="https://www.gstatic.com/firebasejs/3.1.0/firebase.js"></script> <script> // Initialize Firebase // TODO: Replace with your project's customized code snippet var config = { apiKey: "apiKey", authDomain: