angularfire2

Runtime Error this.object.remove is not a function

一世执手 提交于 2019-12-08 04:39:22
问题 In my Ionic app, I can't delete specific key, it keeps telling me that remove is not a function. It seems there are some things changed after the last updates in angularfire2 . It gives me this error: Runtime Error this.employees.remove is not a function TypeError: this.employees.remove is not a function at EmployeesPage.webpackJsonp.76.EmployeesPage.deleteEmployee (http://localhost:8100/build/main.js:319:24) at Object.eval [as handleEvent] (ng:///AppModule/EmployeesPage.ngfactory.js:47:31)

FCM getToken() doesn't return anything

耗尽温柔 提交于 2019-12-08 00:33:13
问题 I'm trying to use Firebase Cloud Messaging with Angular2 but it's like they don't want us to do that @Google. I've been following this and this to be able to stop errors. I'm now facing the following problem: Why does messaging.getToken() returns nothing? No error, no token in the console, nothing. Any help is more than welcome. Thank you. EDIT I've updated the code bellow with my try using onTokenRefresh() . It does not change anything. I feel like it comes from the fact that I'm not really

How do you make a route guard with AngularFire2 wait for auth check

徘徊边缘 提交于 2019-12-07 19:32:46
问题 I want my auth guard to wait until I get the auth back from firebase before it reroutes me. Currently, the auth guard check inits first. I need to make it async in the canActivate, or only populate the canActivate after called. auth.guard.ts import { Injectable } from '@angular/core'; import { Router, CanActivate } from '@angular/router'; import { AuthService } from './auth.service'; @Injectable() export class AuthGuard implements CanActivate { constructor(private authService: AuthService) {

AngularFire2 Complex Query

走远了吗. 提交于 2019-12-07 18:06:25
I need to query a Firebase list based on two keys and values. For example: books -gdhagd342363 status:'Active' authers -yruywert676:'john markos' -eiuqwbj8200:'mark solo' -jdfhs8797429 status:'Active' authers -yruywert676:'john markos' So I want to find how many books are (status=='Active') AND (the key of the authers child == -yruywert676 ). How to implement such query ? 来源: https://stackoverflow.com/questions/42260757/angularfire2-complex-query

Casting FirebaseListObservable results to objects

≯℡__Kan透↙ 提交于 2019-12-07 14:47:39
问题 I'm using angularfire-beta6. Let's say I have a myHeroes:FirebaseListObservable<Hero[]> and use it with an async -pipe in my template I cannot access functions from the Hero class. <ul> <li *ngFor="let hero of myHeroes"> {{hero.someClassFunction()}} </li> </ul> This results in an error: self.context.$implicit.someClassFunction() as hero is not cast to the Hero class. How would I do that? 回答1: You can get an object or a list from the database using list or object function on

When is catch() called when using docRef.get() in FireStore?

泪湿孤枕 提交于 2019-12-07 12:19:36
问题 In Angular 5 with FireStore and angularfire2, when retrieving the contents of a single document using docRef.get() , what scenario would cause the catch statement to be executed? How can I produce such an error? If I interpret the note below the code correctly, it means that if there is no document , it will return null , rather than throwing an error. So my question is, in what case would it actually throw an error and go into the catch statement? 来源: https://stackoverflow.com/questions

Get a single document by foreign key in using RxJs and AngularFirestore

我是研究僧i 提交于 2019-12-07 08:10:48
I've written a query that looks like this: getPaymentByBookingId(id: string): Observable<Payment> { return this.afs.collection<Payment>('payments', ref => ref.where('bookingId', '==', id).limit(1)) .valueChanges() .pipe( flatMap(array => from(array)), first() ); } Where a Payment object has a unique reference to a Booking id. I want to find the Payment for a given ID. This seems like quite a convoluted way to right this query. Is there a simpler way to do this - including if there is a code smell here that makes this hard? You can do it solely using Javascript native array API .find() , and it

How to retrieve the Id of a single Firestore document?

烈酒焚心 提交于 2019-12-07 07:51:25
问题 This is my code: import { Component, OnInit } from '@angular/core'; import { AngularFirestore , AngularFirestoreCollection , AngularFirestoreDocument } from 'angularfire2/firestore'; import { Observable } from 'rxjs/Observable'; interface Country { id?: string; name?: string; code?: string; flag?: string; continent?: string; } @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { title =

How to use snapshotChanges() method to get both key value and filter the data?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 02:12:04
问题 I'm working on an Angular Firebase Project, where I need to filter my database as well get the key values. Currently I'm using valueChanges() method in my service code ( inside getUnreadBooks and getFavoriteBooks methods, as shown below ) to get the data and filter it. But it gives me key value as 'undefined', when I try to get key value inside my template file. I tried to go with snapshotChanges() method, but can't work around how to use it to get key values along with filtering the data .

Angular5 what's happened with valuechanges() function ? (angularfire2)

依然范特西╮ 提交于 2019-12-06 15:17:46
问题 I try to understand .valueChanges() and .subscribe() I use AngularFire2 and Angular5 My code works but I don't understand how it works. My Component : ngOnInit() { this.itemService.getLastUnicorns().subscribe(items => { this.items = items; console.log(items); }); } console.log give a beautiful array : Array [ {…}, {…} ] My service : getLastUnicorns() { this.items = this.afs.collection('unicorns', ref => ref.limit(2)).valueChanges(); console.log(this.items); return this.items; } console.log