angularfire2

Firebase Firestore get() not working

試著忘記壹切 提交于 2019-12-04 03:28:42
The part it doesn't like is the get() method in ngOnInit(). Is says, "[ts] Property 'get' does not exist on type 'AngularFirestoreDocument<{}>'." I looked here: https://firebase.google.com/docs/firestore/query-data/get-data and it shows to use get() method for a single doc, but it just doesn't like that method for me? import { Component, OnInit, Pipe } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { Router, ActivatedRoute } from '@angular/router'; import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from

Access authenticated data with AngularFire2

孤者浪人 提交于 2019-12-03 21:25:49
I am using AngularFire2 in an Angular2 project to do a very basic task, login and then show the logged in users information on the page. The seemingly simple snag I've hit is that I need to know the users UID to request that data from Firebase (my permissions state can only access key inside "/users" with own UID - pretty standard). I discovered in order to get the UID I need to subscribe to the af.auth observable and then inside there request the user data using af.auth.uid - which I've done successfully. I've also noted that af.database.object creates another observable, which I can in

how to get data within firebase, when we have many to many relationship

吃可爱长大的小学妹 提交于 2019-12-03 17:26:35
I read this question Many to Many relationship in Firebase , and here describes how to create or structure many to many relationship within firebase(nosql database), and it is pretty easy, companyContractors companyKey1 contractorKey1: true contractorKey3: true companyKey2 contractorKey2: true contractorCompanies contractorKey1 companyKey1: true, companyKey2: true contractorKey2 companyKey2: true contractorKey3 companyKey1: true but when i want to get all contractors specific company, can i do it using only one request? because in this case i get only list of id, and after there, using js loop

Firebase error messages in different languages?

牧云@^-^@ 提交于 2019-12-03 17:17:36
问题 Showing the Firebase error messages (error.message) in the view results in english error descriptions (e.g. for Authentication errors, if user credetials contain errors). How would you display the messages in different languages (best case: in the phone's language)? 回答1: This is impossible right now. What I recommend is to use the erros code (error.code) that is a unique error code and with that you can create something to bind this errors code to your own text/language. There is an available

angularfire2 best way to increment a value?

喜欢而已 提交于 2019-12-03 16:29:07
I searched in many forums, questions, in doc but can't find the correct solution. Problem What is the best way to increment a value using angularfire2 ? I saw we could use [transaction()][] but it's not for angularfire2 actually. Or with snapshot ? user.service.ts incrementLike(userToIncrementLike){ this.af.database.object('users/' + userToIncrementLike.uid).subscribe((userObject) => { var newUser = { likes: userObject.likes + 1 }; }); this.af.database.object('users/' + userToIncrementLike.uid).update(newUser); } I tried also in this way : incrementLike(userToIncrementLike){ let obs = this.af

Firebase How to update multiple children?

放肆的年华 提交于 2019-12-03 15:35:44
I have parent with many children like this: Parent:{ "childe1":"data", "childe2":"data", "childe3":"data", "childe4":"data", "childe5":"data" } How can I update the children [ childe1 , childe2 , childe3 ] at same time, preventing any other user from updating them at same time? Frank van Puffelen To update multiple properties at the same time, you can run an update() call: ref.child("Parent").update({ childe1: "newdata", childe2: "newdata", childe3: "newdata" }); You can even specify paths as the keys, in case the properties are at different levels in the tree. Even though that doesn't seem to

Using BehaviorSubject in auth-guard's canActivate

孤街醉人 提交于 2019-12-03 15:06:13
问题 What I want to achieve: I want to share authentication state across my application using BehaviorSubject. I use the authentication state e.g. inside an auth-guard to prevent the user from visiting login/register pages when the user already is authenticated. Problem: because the BehaviorSubject has a initial value, which is false (not logged in), it seems that the auth-guard takes this first value, instead of waiting for the uid-sync. AuthInfo (Auth state store): export class AuthInfo {

AngularFireList is not assignable to type 'Observable<Response>

廉价感情. 提交于 2019-12-03 13:14:52
I have an Ionic page which is querying FirebaseListObservable to make dynamic searching on ion-searchbar. It works well with Angularfire2@4.0.0-rc.0 and firebase@4.5.0. After upgrading new release AngularFire 5.0 I get an issue about FirabaseListObservable has no exported from new Api. import { Component } from '@angular/core'; import { IonicPage, NavParams, ViewController } from 'ionic-angular'; import {AngularFireDatabase, FirebaseListObservable} from 'angularfire2/database'; import { Observable} from 'rxjs'; import { Response } from '@angular/http'; @IonicPage() @Component({ selector: 'page

How to mock AngularFire 2 service in unit test?

纵饮孤独 提交于 2019-12-03 11:33:56
问题 I'm trying to set up unit tests for a sample Angular 2 app using AngularFire 2 auth, the component is fairly simple: import { Component } from '@angular/core'; import { AngularFire, AuthProviders } from 'angularfire2'; @Component({ moduleId: module.id, selector: 'app-root', templateUrl: 'app.component.html', styleUrls: ['app.component.css'] }) export class AppComponent { isLoggedIn: boolean; constructor(public af: AngularFire) { this.af.auth.subscribe(auth => { if (auth) { this.isLoggedIn =

'query' does not exist in type 'QueryFn' | angularfire2

余生长醉 提交于 2019-12-03 09:32:00
Argument of type '{ query: { limitTolast: number; orderByKey: boolean; }; }' is not assignable to parameter of type 'QueryFn'.Object literal may only specify known properties, and 'query' does not exist in type 'QueryFn'. package.json "angularfire2": "^5.0.0-rc.3", "firebase": "^4.5.1", chat.service.ts getMessages(): FirebaseListObservable<ChatMessage[]> { return this.db.list('messages', { query: { limitTolast : 25, orderByKey: true} }); } Orlandster It's not working, because AngularFire expects a function to be passed as a second argument. I think your example was the right way to go during