How can you get ref's with dynamic uri's with $firebaseRefProvider?

By : jamie

With $firebaseRefProvider is used to promote DI in angular for testing. Trying to use in an app to inject a reference based on the currentUser.

There is no documentation on it. Did find a video on Firebase Youtube channel. For example:

var config = {
    apiKey: 'somekey',
    authDomain: 'someAuthDomain',
    databaseURL: '',

angular.module('app').config(function($firebaseRefProvider) {
        default: config.databaseURL,
        peopleRef: `${config.databaseURL}/people`

So I wanted to use it to update a user feed like so:

     .service('FbArrayService', ($firebaseRef, $firebaseArray, $firebaseAuth)  => {
        var vm = this
        vm.currentUser = $firebaseAuth.$getAuth();
        vm.currentUserFeed = $firebaseArray($firebaseRef.child(`feeds/${vm.currentUser}`));
       .controller('MyController', (FbArrayService) => {
       var userfeed = FbArrayService.currentUserFeed; 

Problem: Getting error --

child is not a method of $firebaseRef provider

Isn't there a way to get a child ref of the root ref from the ref provider?

By : jamie


Okay after playing around with it for a while I finally realized that is plain js logic that I was overlooking. But you never know within an api.

 vm.currentUserFeed = $firebaseArray($firebaseRef.child(`feeds/${vm.currentUser}`));

needs have the .default (which actually references the root) so the child method can be used.

 vm.currentUserFeed = $firebaseArray($firebaseRef.default.child.(`feeds/${vm.currentUser}`));

I guess I thought the .default property was automatically given to the base provider

By : jamie

Try with this:

var ref = firebase.database().ref().child('feeds/${vm.currentUser}');


Because your assumption is wrong. You expect new Vector3(0,0,0) and new Vector3(Screen.width, 0, 0) to be in screen space (left & right edge of screen I believe) but in fact they are in world space (Vector3(0,0,0) is the world's origin, not the edge of screen).

You can try this. Basically, this code moves your object to where you tap.

void OnMouseUp()
    // Cast a ray from camera through mouse position
    Ray ray = camera.ScreenPointToRay(Input.mousePosition);
    RaycastHit hitInfo;
    Physics.Raycast(ray, out hitInfo);
    // Lerp to the impact point
    transform.position = Vector3.Lerp(transform.position, hitInfo.point, 2f * Time.deltaTime);
By : Loop

This video can help you solving your question :)
By: admin