sirvon sirvon - 5 months ago 28
Javascript Question

Firebase + Angularjs + Python

Ok, I'm using the angularFire-seed repo to test out how I would connect angularjs+firebase+python-firebase library.

My goal is to add stuff to firebase from python scripts and have it show on a webpage.

this is a controller:

......
angular.module('myApp.controllers', [])
.controller('MyCtrl1', ['$scope', 'FBURL', 'angularFire', function($scope,
FBURL, angularFire) {
angularFire(FBURL+'/syncedValue', $scope, 'syncedValue', '');
}])
......


this is the view:

......
<h4>{{syncedValue}}</h4>
<input ng-model="syncedValue" type="text" />
......


Everything works fine:

enter image description here




firebase debugger

It Works! When I input stuff on the webpage, it shows in the firebase debugger.

Now I'm doing this in python:

from firebase import Firebase
f = Firebase("https://xxxxx.firebaseio.com/syncedValue")
r = f.update({"syncedValue": "3433"})


That makes a child to syncedValue:

firebase debugger

r = f.push({"syncedValue": "3433"})


That makes a child with a uid:

enter image description here

But I want to simply just update the syncedValue key's value without adding any child, like this...



Prollie something in angularjs i'm not understanding.

Answer

I got it!

   from firebase import Firebase
   f = Firebase("https://xxxxx.firebaseio.com/syncedValue")
   r = f.update({"syncedValue": "3433"})**strong text**

that code updates a child of syncedValue so....

I just simply made a child in the controller:

  ......
angular.module('myApp.controllers', [])
   .controller('MyCtrl1', ['$scope', 'FBURL', 'angularFire', function($scope,
   FBURL, angularFire) {
   angularFire(FBURL+'/syncedValue/1', $scope, 'syncedValue', '');
   }])
......

enter image description here