angularfire2

Angular2 - Change detection not showing unless clicked

荒凉一梦 提交于 2019-12-30 08:36:13
问题 I have an component in which you can enter some search terms and it will filter the content using a *ngFor loop. The trouble is when I enter a search term I need to click the screen for the update to take effect visually. Here is the part of the html code in which the loop occurs: <li *ngFor="let item of posts | reverse; let i = index; "> <div class="media" *ngIf="item.doesContainTags(searchTags)"> The code that executes on the input field where you enter the tags to search for is:

Firestore + AngularFire2 pagination ( query items by range - .startAfter(lastVisible) )

倾然丶 夕夏残阳落幕 提交于 2019-12-30 07:12:17
问题 In a component I want to pull a range of items from FireStore, for ex. from 0 to 5, from 5 to 10 etc. I found this in FireStore's docs, but they dont use AngularFire2 so as harder I tried to refactor as bigger mess I got. I made it working by simply splice() 'ing: service -> topFirstScores(): AngularFirestoreCollection<Score> { return this.fireRef.collection('scores', r => r .orderBy('score', 'desc').limit(6) ); } component -> $scores = new Subject(); this.scores$ = this.$scores.asObservable(

How to add timestamp to every collection insert,update in Cloud Functions for firestore database

别说谁变了你拦得住时间么 提交于 2019-12-29 08:04:33
问题 I have a firestore collection called Posts I make an insert on the client side and it works. I want to add the createdAt and updatedAt fields to every insert in my posts collection firestore using firebase functions. 回答1: In order to add a createdAt timestamp to a Post record via a Cloud Function, do as follows: exports.postsCreatedDate = functions.firestore .document('Posts/{postId}') .onCreate((snap, context) => { return snap.ref.set( { createdAt: admin.firestore.FieldValue.serverTimestamp(

How to add timestamp to every collection insert,update in Cloud Functions for firestore database

佐手、 提交于 2019-12-29 08:02:07
问题 I have a firestore collection called Posts I make an insert on the client side and it works. I want to add the createdAt and updatedAt fields to every insert in my posts collection firestore using firebase functions. 回答1: In order to add a createdAt timestamp to a Post record via a Cloud Function, do as follows: exports.postsCreatedDate = functions.firestore .document('Posts/{postId}') .onCreate((snap, context) => { return snap.ref.set( { createdAt: admin.firestore.FieldValue.serverTimestamp(

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

笑着哭i 提交于 2019-12-28 16:51:09
问题 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 //

Unit Testing a Service That Uses AngularFireAuth and Mocking authState

回眸只為那壹抹淺笑 提交于 2019-12-28 06:51:32
问题 I have been going round in circles trying to unit test a Service ( AuthService ) that depends upon AngularFireAuth . I am trying to find a way to mock, or highjack the Observable AngularFireAuth.authState instead of the Service actually talking to Firebase. Here is my test spec: import { inject, TestBed } from '@angular/core/testing'; import { AngularFireModule } from 'angularfire2'; import { AngularFireAuth, AngularFireAuthModule } from 'angularfire2/auth'; import * as firebase from

How to implement drag and drop in Angular2 with a firebase list / FirebaseListObservable

大城市里の小女人 提交于 2019-12-25 09:17:38
问题 I am trying to implement drag and drop into a list using angular2, firebase and dragula. I'm not tied to using dragula if there is a better module already built, but it seems simple. So far I get errors because dragula is trying to reorder the list as if it were a normal array. <ul class="list-group" [dragula]="statusList" [dragulaModel]='statusService.$statuses'> <li *ngFor="let status of statusService.$statuses | async" class="list-group-item"> <span class="handle"> <img src="../../images

Angular2 UID as primary key using Firebase Database

别说谁变了你拦得住时间么 提交于 2019-12-25 08:48:24
问题 Im creating a signup component in my app using Firebase as Auth method and Database. When I register a new user, a key is generated and then I save all the user info including the UID from authentication in my database. What I want to do is to use UID from authentication as my primary key instead of the key generated by Firebase. This is my code: component.ts signupUser(user: User) { this.firebaseAuth.auth .createUserWithEmailAndPassword(user.email, user.password) .then(value => { console.log

Type 'String' has no compatible call signatures

家住魔仙堡 提交于 2019-12-25 08:09:10
问题 I'm trying to do a multi-path update using Firebase and AngularFire2. However, I'm getting the error above when I use this: let fb = firebase.database().ref(); let key = fb.child('/path').push().key(); Any ideas of how I can get the key after pushing something using AngularFire2? 回答1: As the push method now returns an Observable, the proper way to get the generated $key (using AF2) is doing the following: let fb = this.af.database.list('/path'); fb.push('item').then(res => console.log(res.key

Querying data from AngularFire2 with combinelatest

筅森魡賤 提交于 2019-12-25 07:27:18
问题 I could achieve some filtering behaviour with my question querying subset from angularfire2. Now I want to display these values as a list in Angular using ngFor. In my ts file I have: export class OtherAnimals{ public animalList: Observable<{}>; constructor(public af: AngularFire) { this.animalList = Observable.combineLatest( this.af.database.object('/set1/'), this.af.database.object('/set2/'), // Use the operator's project function to emit an // object containing the required values. (set1,