javascript - AngularFire: $add sets fbUID and custom UID, why? -


before there questions, have function creates custom uid because don't "need" long firebase uid , wanted shorter more easy remember.

anyway, in create-function i'm not sure i'm adding db correctly. here's snippet , below how looks in database.

$scope.create = function(){           // generate shorter random uid (6 chars) replaces long regular firebase uid           letters = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789';           uid_length = 6;           generator = function(){             random = '';             for(var = 0; < uid_length; i++){               random += letters.charat(math.floor(math.random() * letters.length));             }             return random;           }           generator();            var lists = new firebase('https://url.firebaseio.com/lists/' + random);           firebaselists = $firebasearray(lists);            //lists.child(random).set(random);           firebaselists.$add(random).then(function(lists){           }) 

this gives me, example:

lists    0knn8m <- custom uid      -kh6ksxpaaerju: '0knn8m' 

as want things added 0knn8m displayed on page, displays fb uid. of course css 'display:none;' on child shouldn't way around it?

i think, here error:

generator = function(){   random = '';   for(var = 0; < uid_length; i++){     random += letters.charat(math.floor(math.random() * letters.length));   }   return random; } generator();  var lists = new firebase('https://url.firebaseio.com/lists/' + random); 

you calling generator() not assigning result variable. in var lists = new firebase('https://url.firebaseio.com/lists/' + random); variable random undefined. firebase generates it's own id guess. need change 1 thing var random = generator().


Comments

Popular posts from this blog

ruby on rails - Permission denied @ sys_fail2 - (D:/RoR/projects/grp/public/uploads/ -

c++ - nodejs socket.io closes connection before upgrading to websocket -

java - What is the equivalent of @Value in CDI world? -