Search Posts

Category: firebase-database

Retrieving Object from Firebase (AngularFire)

I try to get an object from Firebase with AngularFire and use firebaseObject. However, it did not return an object as I expected. Here is my code (function(){ ‘use strict’; angular.module(‘moiveapp’, [‘ngRoute’],[‘firebase’]) .factory(“Movie”, [“$firebaseObject”, function($firebaseObject) { return function(ID) { // create a reference to the database node where we will store our data var ref = firebase.database().ref(“allmovies”).push(); var movieRef = ref.child(ID); // return it as a synchronized object return $firebaseObject(movieRef); } } ]) .controller(“MovieCtrl”, [‘$scope’,’Movie’, […]

How to loop through child records in firebase?

I’m trying to figure out how to loop through sent_request child which is inside users table and get all user_keys. I tried many ways but it’s not working. table structure: here is my code: getProfileData(emailID) { var ref = firebase.database().ref(‘users’); ref.orderByChild(“email”).equalTo(emailID).once(“value”, (items : any) => { let sent_request : any = []; items.forEach((item) => { sent_request = item.val().sent_request; }); console.log(sent_request); }); } console.log(sent_request) output: How to get user_key from these records? because I want to […]

Why response of firebase realtime database not reflect to html in angularjs

I’m trying to display response of firebase realtime database to HTML page with AngularJS as follow {{ pps }}. Controller.js firebase.database().ref(‘/activeUsers/9791009080’).once(‘value’).then(function(snapshot) { $scope.pps = (snapshot.val() && snapshot.val().msisdn) || ‘Anonymous’; console.log($scope.pps); }); index.html <h1>{{ pps }}</h1> Problem is frontend HTML value is not reflected when I’ve found value inside console.log Please let me know what I’ve missed above code. Source: AngularJS

Sorting an Array of Objects by Elements Stored Elsewhere

If found quite a few answers on here, although may problem is somewhat unique as I am not trying to sort the array of objects by a value stored elsewhere: In the HTML: <div class=”card card-nav-tabs” ng-repeat=”post in latestPosts | limitTo: 7″> Attempting to sort in the Javascript: $scope.latestPosts = $firebaseArray(querylatestPosts); $scope.latestPosts.sort(function(a,b){ return $scope.dataVotes[a.algRef].total – $scope.dataVotes[b.algRef].total }) ; I have a dropdown menu to choose form ‘Latest Posts’ or ‘Top Posts All Time’, hence I […]

Experiences using "FEAN" stack for web application development?

I have recently been looking into technology stacks that I could possible use for a new web application I am considering developing for my final year project. The FEAN stack or Firebase, Express, AngularJS and Node.js stack has recently caught my eye and I was wondering how other developers found using this technology stack? And if there was any opinions/thoughts/recommendations you might have before I start? I know this is just a variation of the […]

Ordering objects in firebase Array in ngRepeat using elements stored at a different location in the database

I want to order the objects in my array in the ngRepeat using values stored in firebase under a different thread. See code and images. I am currently using the following code, it doesn’t give errors but neither does it order my objects according the the amount of votes: ng-repeat=”for in For | orderBy: ‘-dataVotes[for.ref].total’ | limitTo: 30″ This is where i get the dataVotes: firebase.database().ref(“votes”).on(‘value’, function(data) { dataVotes = data.val(); $scope.dataVotes = dataVotes; }); […]

How to return the value/status on Push Method in Nativescript + Firebase Database?

I would like to return the status (OK or NOT_OK) in register method of UserService.ts. Is there way to put return statement in push method of firebase database + nativescript? AppComponent.ts …. export class AppComponent { … signUp() { var result = this.userService.register(this.user); if(result == “OK”) { alert(“Your account was successfully created.”); this.toggleDisplay(); } else if(result == “NOT_OK”) { alert(“Unfortunately we were unable to create your account.”); } } } UserService.ts import { Injectable } […]

how to get last X min – Angularjs

Hello I have connected my ionic app with firebase, I need to get list wich pushed last 5 min ago. I have pushed timestamp in my records in firebase. I have no any code yet for this. but for example: this.transactionsRef = db.list(‘shops’); // Use snapshotChanges().map() to store the key this.transactions = this.transactionsRef.snapshotChanges().map(changes => { return => ({ key: c.payload.key, …c.payload.val() })); }); with this code I can get list of records from firebase. […]

How to call the $firebaseArray in the cloud function of firebase

So in my angular JS web app, I have a function that calls on a node in the firebase database called orderedPlayers and returns it as an array as follows: $firebaseArray(orderedPlayers) .$loaded(function(loadedPlayers) { // function in here }); When attempting to do something similar in the cloud function I am experiencing problems. Is there a way to return the the players node as an array? I know i can access the database as follows: admin.database().ref(‘orderedPlayers’); […]

Next Page »