angularfire

How to roll back changes when there is an error in a promise chain

僤鯓⒐⒋嵵緔 提交于 2020-01-04 09:03:47
问题 In my angular app I want to make changes to several locations in my firebase with a mix of transactions and set. I have written a promise chain with a little help. Now I need to handle any errors that may occur. In the event of an error on any of the promises I would want to roll back any changes made in firebase (the successful promises) and alert the user to the failure. Current code below $scope.addNewPost = function() { var refPosts = new Firebase(FBURL).child('/posts').push(); // Get

How to get specific element and orderby priority in Firebase and Angular

久未见 提交于 2020-01-04 05:25:07
问题 I have a firebase reference like this: $scope.lessons = $firebaseArray(firebase.child('Lessons').orderByChild('courseID').equalTo($state.params.courseID)); I'm outputting the lessons like this: <ul> <li class="lesson" ng-if="lesson.moduleID == module.$id" ng-repeat="lesson in lessons" lessonid="{{lesson.$id}}"> <lessonedit></lessonedit> </li> </ul> I need to order the lessons by priority, but when I add the orderByPriority() function to the end of the firebase reference it says I can only use

Firebase push() vs Angularfire $save()

余生长醉 提交于 2020-01-02 05:19:52
问题 How does angularfire .$save() compare to firebase .push()? I know push() will generate a unique key when data is stored, but I can't recreate the behavior using angularfire. Is there a way or should I be using .push() and if so, in what case would you use $save()? Here is one sample I have using $save()... var fb = new Firebase(FIREBASE_URI).child('Test'); var article = $firebaseObject(fb); article.Foo = "bar"; article.$save().then(function(fb) { console.log(fb.key() === article.$id); // true

Firebase push() vs Angularfire $save()

冷暖自知 提交于 2020-01-02 05:19:08
问题 How does angularfire .$save() compare to firebase .push()? I know push() will generate a unique key when data is stored, but I can't recreate the behavior using angularfire. Is there a way or should I be using .push() and if so, in what case would you use $save()? Here is one sample I have using $save()... var fb = new Firebase(FIREBASE_URI).child('Test'); var article = $firebaseObject(fb); article.Foo = "bar"; article.$save().then(function(fb) { console.log(fb.key() === article.$id); // true

Cordova inAppBrowser won't work with firebaseAuth

北慕城南 提交于 2020-01-01 19:08:33
问题 I am building a hybrid app using the ionic framework. I'm using angularFire 2.0 with Firebase 3.0. I have the cordova plugin "inAppBrowser" installed. In the depreciated Firebase documents, that's all I need to have authWithOAuthPopup() fire up an inAppBrowser window and do the login process. Currently, I am using signInWithPopup() and it does nothing in my iOS app. The app works fine in browser using ionic serve. 回答1: Firebase 3.0 signInWithPopup/Redirect is not currently supported in a

FirebaseListObservable becomes Observable after query

♀尐吖头ヾ 提交于 2020-01-01 12:12:32
问题 I made a small app on firebase. I have been using a type provided by angularfire called a FirebaseListObservable which allows you to observe changes to your data. The problem I'm having is that Angularfire also provides a way to query the data, by attaching / passing in a query object to the request. The following returns a FirebaseListObservable. this.resources$ = <FirebaseListObservable<IResource[]>> this.af.list(`/resources/${this.auth.id}`) as FirebaseListObservable<IResource[]>; //This

Working with AngularFireObject and switchMap

点点圈 提交于 2020-01-01 07:04:27
问题 I really don't know how to fix this. How can I fix this error? in user.service.ts: import { Injectable } from '@angular/core'; import { AngularFireDatabase, AngularFireList, AngularFireObject } from 'angularfire2/database'; import {AppUser} from './models/app.user'; import * as firebase from 'firebase'; import { Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) export class UserService { constructor(private db: AngularFireDatabase) { } save(user: firebase.User) { this.db.object('

Get length of an array returned by firebase

二次信任 提交于 2020-01-01 06:56:09
问题 The usual .length property of the array doesn't work on the arrays returned by firebase. Here is the console.log of the returned array: 0: Object 1: Object 2: Object 3: Object 4: Object $$added: function () { [native code] } $$error: function () { [native code] } $$moved: function () { [native code] } $$removed: function () { [native code] } $$updated: function () { [native code] } $add: function () { [native code] } $destroy: function () { [native code] } $getRecord: function () { [native

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

Get the index ID of an item in Firebase AngularFire

雨燕双飞 提交于 2020-01-01 00:44:32
问题 A similar question was asked here, but the one accepted answer doesn't really answer the question. Using AngularFire, is it possible to to create relational-style databases? Or access the UniqueIDs? When adding nested items to Firebase via AngularFire, each item is actually set under another index numbered numerically. Because of this, I'll need to reference the user's products with the following relative url: users/:id/products My question is, once I have created a user (or anything for that