angularfire2

How to pass a value inside an observable to (click) handler in Angular2

我怕爱的太早我们不能终老 提交于 2020-01-02 07:06:01
问题 I try to learn observable programming with Angular 2 BUT I don't get one important point - how to pass in the value that is in an observable in the (click) event in the template level (without subscribing the observable in the TS file and turn the observable value into member variable). As lots of Firebase experts suggest this "Wherever possible, try to use | async in angular2 and prevent manual subscriptions!" - reason for not wanting to manually subscribe to task$ and turn it into an array.

Firebase Firestore get() not working

点点圈 提交于 2020-01-01 08:57:34
问题 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

Firebase Firestore get() not working

微笑、不失礼 提交于 2020-01-01 08:57:08
问题 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

Access authenticated data with AngularFire2

老子叫甜甜 提交于 2020-01-01 07:28:06
问题 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

How to retrieve data from Firebase to pass into an array in angularfire2/version-5

一个人想着一个人 提交于 2020-01-01 03:41:13
问题 I have some simple entries in Firebase like: All I want is, to get these values (each percentage) and pass them into an array called labels . so that I can use that array in my code. That is my question. Now, to me, it seemed easy but apparently it is not. First of all what I faced is @angularfire version 5 differences in the examples(but easy to understand in their GitHub docs). so secondly, I try to get data with: this.items = db.list('/percentage').valueChanges(); so I do it and check it

Pagination using AngularFire2

雨燕双飞 提交于 2020-01-01 00:52:12
问题 I am building an Ionic2 project, that uses Firebase and I am using AngularFire2. From AngularFire2 documentation, I was able to get things like: const queryObservable = af.database.list('/items', { query: { orderByChild: 'size', equalTo: subject } }); This works well. I have around 300-400 records, but I can't pull it all in one API call. So I am trying to implement pagination. I tried many things. What I want to implement is this: StartAt(), endAt() I tried to pass it through the query

Three way binding in Angular 2 and Angularfire2

一世执手 提交于 2019-12-31 11:07:07
问题 I am trying to three-way bind an input element to firebase database in Angular.js 2 (2.0.0-rc.4), using AngularFire 2 (2.0.0-beta.2). I have a very simple html like: <form (ngSubmit)="onSubmit()" #commentForm="ngForm"> <input [(ngModel)]="model.author" type="input" name="author" required> </form> In my component, to save and retrieve contents of this input to firebase, I have an implementation like this: export class CommentFormComponent implements OnInit, AfterViewInit { @ViewChild(

Test for rejected promise with Jasmine

空扰寡人 提交于 2019-12-31 05:11:10
问题 In my Angular2 app which uses AngularFire2, I have an AuthService which tries to authenticate anonymously with Firebase. I am trying to write a test that expects AngularFireAuth 's signInAnonymously to return a rejected promise; for authState to be null and an error to be thrown. I an new to Jasmine and testing in general but I think I may need to be using asynchronous tests but I'm getting quite stuck. Here is a simplified AuthService : import { Injectable } from '@angular/core'; import {

Get documents names in Firestore

雨燕双飞 提交于 2019-12-31 04:30:10
问题 When I get several documents from a collection, the result is only an array with each doc data. firestore.collection("categories").valueChanges().subscribe(data => { console.log(data); // result will be: [{…}, {…}, {…}] }; How can I get the name of each doc? The ideal result would look like this: {"docname1": {…}, "docname2": {…}, "docname3": {…}} 回答1: When you need to access additional metadata like the key of your Document, you can use the snapshotChanges() streaming method. firestore

Firebase Real Time Database Structure for File Upload

走远了吗. 提交于 2019-12-31 04:11:38
问题 I am working on my first Firebase project using AngularFire2. Below is the overall design of my learning project. Users uploads photos and it's stored in the Firebase storage as images. The uploaded photos are listed in the homepage sorted based on timestamp. Below is the structure that I have now when I started. But I feel difficulty when doing joins. I should be able to get user details for each uploads and able to sort uploads by timestamp. User: - Name - Email - Avatar Uploads: - ImageURL