angularjs elasticsearch typeahead matches undefined - angularjs

i'm using :
AngularJs : AngularJS v1.2.22
Bootstrap : Bootstrap v3.1.1 + ui-bootstrap-tpls-0.11.0.js
Elasticsearch.angular : elasticsearch - v2.4.0 - 2014-07-30
I work on a front end with angular and i want to make an autocompleted input using twitter-bootstap typeahead on an elasticsearch document.
I can query elasticsearch with angularJs and get the data correctly (by putting them in the scope) but when i try an asynchrone query it failed with an error **"Error: matches is undefined" ( full error her : http://pastebin.com/CJSubYbp )
In angularjs, service for elasticsearch :
interfaceApp.service('elasticQuery', function (esFactory) {
return esFactory({ host: 'localhost:9200' });
});
my controller :
'use strict';
/* Controllers */
var searchSimpleModules = angular.module('searchSimpleModules', ['ngRoute']);
searchSimpleModules.controller('searchSimpleCtrl', function ($scope, $rootScope, $routeParams, $location, elasticQuery) {
$scope.simplequery = "";
$scope.autocomplete = function(value) {
$scope.simplequery = value;
var index_p = 'donnees';
var size_p = 50;
var body_p = {
"query": {
"query_string": { "query" : value +"*" }
}
};
elasticQuery.search({
index: index_p,
size: size_p,
body: body_p
}).then(function (response) {
$scope.hits= response.hits.hits;
});
};
$scope.find = function () {
elasticQuery.search({
index: 'donnees',
size: 50,
body: { "query": { "query_string": { "query" : "P000023*" } } }
}).then(function (response) {
$scope.hits= response.hits.hits;
});
};
});
the html input:
<input required type="text"
popover="Rechercher un terme sur toute la partie {{simplesearch.domaine}}.Il est possible d'utiliser des *,? et double quote."
popover-trigger="focus"
placeholder="recherche globale"
class="form-control"
typeahead="entree for entree in autocomplete($viewValue)"
ng-model="simplequery"
>
In the firebug console i see that i get the error before the "http.get()" made by the service.
I make many search to debug this but i can't get out of it.
I read http://www.elasticsearch.org/guide/en/elasticsearch/client/javascript-api/current/browser-builds.html
Any advice are welcomed. thanks
Best regards

update 2: using elasticsearch-angular.js :
autocomplete/typeahead angularjs bootstrap on elasticsearch
( it was not working because of the return in "return elasticQuery.search({...})" was missing )

update 1 : i found another solution but not using the elastic.js
<input required type="text"
popover="Rechercher un terme sur toute la partie {{simplesearch.domaine}}.Il est possible d'utiliser des *,? et double quote."
popover-trigger="focus"
placeholder="recherche globale"
class="form-control search-query"
ng-model="simplequery"
typeahead="entree as entree.data for entree in autocomplete($viewValue) | filter:$viewValue | limitTo:15 "
typeahead-on-select="onSelect($model)"
/>
js:
$scope.simplequery = {id:"",data:""};
$scope.autocomplete = function(val) {
var body = '{"fields" : [ "O_OCCURRENCEID","C_COLLECTIONID", "C_COLLECTIONCODE", "I_INSTITUTIONID", "I_INSTITUTIONCODE" ], "query" : {"query_string" : { "query" : "*'+val+'*" }},"highlight":{"pre_tags" : ["<strong>"],"post_tags" : ["</strong>"],"fields":{"*": {}}}}';
return $http.get($rootScope.elastic_host + 'specimens/_search?', {
params: { // q: val
source : body
}
}).then(function(res){
var keywords = [];
for (var i in res.data.hits.hits) {
var highlights = (res.data.hits.hits[i]).highlight;
var ligneTmp ="";
for(var j in highlights){
ligneTmp += highlights[j][0] + " ";
}
keywords[i]= {id:"id"+i,data:ligneTmp};
}
return keywords;
});
};
$scope.onSelect = function (selection) {
$scope.simplequery.data = selection.data;
$scope.simplequery.id = selection.id;
...
};

Related

Pass md-on-demand to md-autocomplete

I would like display in md-autocomplete large list (around 50 000 records).
Autocomplete directive uses mdVirtualRepeat which provide infinity scrolling. I couldn't find way to pass md-on-demand option. Maybe someone find way to do that.
I really appreciate any help you can provide
UPDATE
I forget to share the code. I haven't problem with code performance but when list is rendering app is not responsive. In my opinion problem is in virtual rendering which still try to render whole list instead of visible part.
PS. I know $scope is bad but I'm using this example in angular-formly.
JS
$scope.to.options = [];
$scope.ctrl = {
selectedItem: null,
isDisabled: $scope.to.disabled,
noCache: $scope.to.noCache,
placeholder: $scope.to.placeholder || 'Wybierz element',
minLength: $scope.to.minLength || 0,
querySearch: querySearch,
searchTextChange: searchTextChange,
selectedItemChange: selectedItemChange,
delay: $scope.to.delay || 350,
options: []
};
if ($scope.to.dictId) {
dictionariesRepository.get($scope.to.dictId).then(function (res) {
$scope.ctrl.options = createOnDemandObject(res.Data.map(function (elem) {
return { value: elem[$scope.to.FieldVal], name: getLabel($scope.to.FieldFormula, elem) };
}));
var val;
if ((val = getValue())) {
var selected = $scope.ctrl.options.filter(function (elem) {
return elem.value == val;
})[0];
if (selected) {
$scope.ctrl.selectedItem = selected;
}
}
});
}
function createOnDemandObject(list) {
return {
list: list,
getLength: function () {
return this.list.length
},
getItemAtIndex: function (index) {
return this.list[index];
}
}
}
function searchTextChange(text) {
//$log.info('Text changed to ' + text);
}
function selectedItemChange(item) {
var getter = $parse($scope.options.key);
var setter = getter.assign;
setter($scope.model, item[$scope.to.FieldVal]);
}
function querySearch(query) {
var options = $scope.ctrl.options;
return query ? options.filter(createFilterFor(query)) : options;
}
function createFilterFor(query) {
var lowercaseQuery = angular.lowercase(query);
return function filterFn(elem) {
return (elem.name.indexOf(lowercaseQuery) === 0);
};
}
HTML
<md-autocomplete ng-disabled="ctrl.isDisabled" md-no-cache="ctrl.noCache" md-selected-item="ctrl.selectedItem" md-search-text-change="ctrl.searchTextChange(ctrl.searchText)"
md-delay="ctrl.delay"
md-search-text="ctrl.searchText" md-selected-item-change="ctrl.selectedItemChange(item)"
md-items="item in ctrl.querySearch(ctrl.searchText)"
md-on-demand
md-item-text="item.name" md-min-length="ctrl.minLength" placeholder="{{ctrl.placeholder}}">
<md-item-template>
<span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.name}}</span>
</md-item-template>
<md-not-found>
Nie znaleziono pasującego wyniku dla "{{ctrl.searchText}}".
</md-not-found>
</md-autocomplete>

Field update after autocompletion with angularJS

I'm quite new to AngularJS and struggling a bit to have some input fields updated after an autocompletion event using google maps.
The idea is that when the user inputs his city/zip code, I would update 3 fields which are themselves linked to an object.
So far, I managed to have a working code except that sometimes the fields are not updated immediately : I have to autocomplete twice so that the good value will appear in the fields.
I've tweaked an existing angular directive in order to get what I want but since this is new to me, I dont know if I'm using the correct approach.
Below is the JS directive I use :
angular.module( "ngVilleAutocomplete", [])
.directive('ngAutocomplete', function($parse) {
return {
scope: {
details: '=',
ngAutocomplete: '=',
options: '=',
data: '='
},
link: function(scope, element, attrs, model) {
//options for autocomplete
var opts
//convert options provided to opts
var initOpts = function() {
opts = {}
if (scope.options) {
if (scope.options.types) {
opts.types = []
opts.types.push(scope.options.types)
}
if (scope.options.bounds) {
opts.bounds = scope.options.bounds
}
if (scope.options.country) {
opts.componentRestrictions = {
country: scope.options.country
}
}
}
}
initOpts()
//create new autocomplete
//reinitializes on every change of the options provided
var newAutocomplete = function() {
scope.gPlace = new google.maps.places.Autocomplete(element[0], opts);
google.maps.event.addListener(scope.gPlace, 'place_changed', function() {
scope.$apply(function() {
scope.details = scope.gPlace.getPlace();
//console.log(scope.details)
var HasCP = false;
for (var i=0 ; i<scope.details.address_components.length ; i++){
for (var j=0 ; j<scope.details.address_components[i].types.length ; j++){
if (scope.details.address_components[i].types[j] == 'postal_code' && scope.data.CP != 'undefined'){
scope.data.CP = scope.details.address_components[i].long_name;
HasCP = true;
} else if (scope.details.address_components[i].types[j] == 'locality' && scope.data.Ville != 'undefined') {
scope.data.Ville = scope.details.address_components[i].long_name;
} else if (scope.details.address_components[i].types[j] == 'country' && scope.data.Pays != 'undefined') {
scope.data.Pays = scope.details.address_components[i].long_name;
}
}
}
if (!HasCP){
var latlng = {lat: scope.details.geometry.location.lat(), lng: scope.details.geometry.location.lng()};
var geocoder = new google.maps.Geocoder;
geocoder.geocode({'location': latlng}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
for (var i=0 ; i<results[0].address_components.length ; i++){
for (var j=0 ; j<results[0].address_components[i].types.length ; j++){
if (results[0].address_components[i].types[j] == 'postal_code' && scope.data.CP != 'undefined'){
scope.data.CP = results[0].address_components[i].long_name;
console.log('pc trouvé :' + scope.data.CP);
}
}
}
}
});
}
//console.log(scope.data)
scope.ngAutocomplete = element.val();
});
})
}
newAutocomplete()
//watch options provided to directive
scope.watchOptions = function () {
return scope.options
};
scope.$watch(scope.watchOptions, function () {
initOpts()
newAutocomplete()
element[0].value = '';
scope.ngAutocomplete = element.val();
}, true);
}
};
});
The matching HTML code is below :
<div class="form-group">
<lable>Code postal : </label>
<input type="text" id="Autocomplete" class="form-control" ng-autocomplete="cities_autocomplete" details="cities_autocomplete_details" options="cities_autocomplete_options" data="client" placeholder="Code postal" ng-model="client.CP" />
</div>
<div class="form-group">
<lable>Ville : </label>
<input type="text" id="Autocomplete" class="form-control" ng-autocomplete="cities_autocomplete" details="cities_autocomplete_details" options="cities_autocomplete_options" data="client" placeholder="Ville" ng-model="client.Ville" />
</div>
<div class="form-group">
<lable>Pays : </label>
<input type="text" class="form-control" name="Pays" ng-model="client.Pays" placeholder="Pays" />
</div>
You'll see that I pass the "client" object directly to my directive which then updates this object. I expected angular to update the html page as soon as the values of the client object are updated but I will not always be the case :
If I search twice the same city, the values are not updated
If I search a city, Google wont send me a zip code so I have to do another request to the geocoding service and I get the zipcode in return but while my client.CP field is correctly updated, changes are not visible in the CP input field until I do another search.
Thanks in advance for any advice on what I'm doing wrong.

autocomplete/typeahead angularjs bootstrap on elasticsearch

I was looking for a working solution to get autocomplete/typeahead with angularjs&bootstrap on elasticsearch server.
This is a working solution, not a question, but I want to share it hope it will help:
the html code to call the autocomplete function :
<input required type="text"
popover-trigger="focus"
placeholder="recherche globale"
class="form-control"
ng-model="simplequeryInput"
ng-model-onblur focus-on="focusMe"
ng-click="searchSimple=true" ng-keyup="$event.keyCode == 13 ? submitSimple() : null"
typeahead="item for item in autocomplete($viewValue) | limitTo:15 "
typeahead-on-select="simplequeryInput=$model"
/>
Include the elasticsearch (v2.4.0) script
available here
my elasticsearch service
interfaceApp.service('elasticQuery', function ($rootScope,esFactory) {
return esFactory({ host: $rootScope.elastic_host}); //'localhost:9200'
});
angularjs code querying elasticsearch :
'use strict';
var searchModules = angular.module('searchModules', ['ngRoute','ngDialog']);
searchModules.controller('searchCtrl', function (ngDialog,$scope, $http,$rootScope, elasticQuery) {
...
$scope.autocomplete = function(val) {
var keywords = [];
keywords.push(val);
// THIS RETURN IS VERY IMPORTANT
return elasticQuery.search({
index: 'YOUR_INDEX_NAME',
size: 15,
body: {
"fields" : ["T_FAMILY","T_GENUS","T_SCIENTIFICNAME"], // the fields you need
"query" : {
"bool" : {
"must" : [
{
"query_string" : {
"query" : "T_FAMILY:"+val // i want only source where FAMILY == val
}
}
]
}
}
}
}).then(function (response) {
for (var i in response.hits.hits) {
var fields = (response.hits.hits[i]).fields;
var tmpObject = fields["T_FAMILY"] +" " + fields["T_GENUS"] + " ( "+fields["T_SCIENTIFICNAME"] + " )";
keywords.push(tmpObject);
}
return keywords;
});
}
});
hope it helps

Getting an 'Error: [$injector:unpr] Unknown provider: ' error

I'm trying to creata a dynamic drop down select menu. I'm getting an unknown provider error relating to a function I'm using to create a date range. Here is my code:
HTML
<ul data-role="listview" data-inset="true" >
<li>
<select id="makeSuperCategory" data-role="listview" ng-options="catagory as catagory.text for catagory in catagories.cast " ng-model="itemsuper" ng-change="changeData()">
</select>
</li>
</ul>
<ul data-role="listview" data-inset="true">
<li>
<select data-role="listview" ng-options="type as type.text for type in types.cast " ng-model="item1" ng-change="update()">
</select>
</li>
</ul>
Factories
var myApp = angular.module('myApp',[]);
myApp.factory('catagories',function(){
var makes = {};
makes.cast = [
{
value: "acura",
text: "Acura"
},
{
value: "audi",
text: "Audi"
},
{
value: "geo",
text: "Geo"
},
{
value: "hummer",
text: "Hummer"
},
];
return makes;
});
myApp.factory('acura',function( production_range,makesProductionEnded, makesInProduction){
var endedProductionObject = makesProductionEnded.filter(function( obj) {
return obj.make === this;
});
$scope.acura ={};
$scope.start = 1986 <!-- date Honda began production of the Acura product line -->
<!-- Set the most recent year option if still in production according to current month and model year change over October -->
$scope.setEnd = function(){
if($inArray(this, makesInProduction) > 0){
if(new Date().getMonth() < 10){
end = new Date().getFullYear();
} else {
end = new Date().getFullYear() + 1;
}
<!-- Set most recent year option if no longer in production according to year property value of object that matches this make in the endedProductionObject array -->
} else {
end = endedProductionObject.year;
}
return end;
}
$scope.acura.cast = [];
angular.foreach(years, function(value, year){
acura.cast.push(acura[year] = value);
});
return acura;
});
myApp.factory('audi',function(){
var audi = {};
audi.cast = [
<!--This will follow a similar pattern as acura once that is resolved -->
];
return audi;
});
myApp.factory('geo',function(){
var geo = {};
geo.cast = [
<!--This will follow a similar pattern as acura once that is resolved -->
];
return geo;
});
myApp.factory('hummer',function(){
var hummer = {};
hummer.cast = [
<!--This will follow a similar pattern as acura once that is resolved -->
];
return hummer;
});
Controller
myApp.controller('makeTypeCtrl',function($scope, acura, audi, geo,hummer, setNulls, catagories, production_range){
<!-- Push the model years into the years array according to the start and end dates -->
$scope.production_range = function(start, end){
var years = [];
for(var year = start; year <= end; year++){
years.push(year);
}
return years;
}
<!-- Defines the makes no longer in production and the date production ended for that make -->
$scope.makesProductionEnded = [{make:'eagle', year:1999}, {make:'geo', year:1997}]
<!-- Defines makes still in production -->
$scope.makesInProduction = ['acura', 'audi'];
$scope.catagories = catagories;
$scope.types = setNulls;
$scope.changeData = function() {
if($scope.itemsuper.text == "Acura") {
$scope.types = acura;
} else if($scope.itemsuper.text == "Audi") {
$scope.types = audi;
} else if($scope.itemsuper.text == "Geo") {
$scope.types = geo;
} else if($scope.itemsuper.text == "Hummer") {
$scope.types = hummer;
} else {
$scope.types = setNulls;
}
}
});
Here is a link to a jsFiddle
The issue is that you are trying to inject production_range into your acura factory. But production_range is a variable on a controller's scope, not a factory or service that can be injected.
The second parameter to a factory should be a function that takes dependencies as its parameters. By dependencies I mean factories / services or anything else thats created from a provider, see https://docs.angularjs.org/guide/services and https://docs.angularjs.org/guide/providers.
Read this as well: https://docs.angularjs.org/guide/di

Should $bind save child data added in an ng-repeat

Hi I have a problem with $bind, I am binding a model and outputting the models via a ng-repeat. The ng-repeat outputs the stored data and also offers some fields for adding/changing data. The changes are reflected in the scope but are not being synced to Firebase.
Is this a problem with my implementation of $bind?
The HTML:
<iframe id="fpframe" style="border: 0; width: 100%; height: 410px;" ng-if="isLoaded"></iframe>
<form>
<ul>
<li ng-repeat="asset in upload_folder" ng-class="{selected: asset.selected}">
<div class="asset-select"><input type="checkbox" name="selected" ng-model="asset.selected"></div>
<div class="asset-thumb"></div>
<div class="asset-details">
<h2>{{asset.filename}}</h2>
<p><span class="asset-filesize" ng-if="asset.size">Filesize: <strong><span ng-bind-html="asset.size | formatFilesize"></span></strong></span> <span class="asset-filetype" ng-if="asset.filetype">Filetype: <strong>{{asset.filetype}}</strong></span> <span class="asset-dimensions" ng-if="asset.width && asset.height">Dimensions: <strong>{{asset.width}}x{{asset.height}}px</strong></span> <span class="asset-type" ng-if="asset.type">Asset Type: <strong>{{asset.type}}</strong></span></p>
<label>Asset Description</label>
<textarea ng-model="asset.desc" cols="10" rows="4"></textarea>
<label>Creator</label>
<input type="text" ng-model="asset.creator" maxlength="4000">
<label>Release Date</label>
<input type="text" ng-model="asset.release">
<label for="CAT_Category">Tags</label>
<input type="text" ng-model="asset.tags" maxlength="255">
</div>
</li>
</ul>
</form>
The Controller: (fpKey is a constant that stores the Filepicker API key)
.controller('AddCtrl',
['$rootScope', '$scope', '$firebase', 'FBURL', 'fpKey', 'uploadFiles',
function($rootScope, $scope, $firebase, FBURL, fpKey, uploadFiles) {
// load filepicker.js if it isn't loaded yet, non blocking.
(function(a){if(window.filepicker){return}var b=a.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===a.location.protocol?"https:":"http:")+"//api.filepicker.io/v1/filepicker.js";var c=a.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c);var d={};d._queue=[];var e="pick,pickMultiple,pickAndStore,read,write,writeUrl,export,convert,store,storeUrl,remove,stat,setKey,constructWidget,makeDropPane".split(",");var f=function(a,b){return function(){b.push([a,arguments])}};for(var g=0;g<e.length;g++){d[e[g]]=f(e[g],d._queue)}window.filepicker=d})(document);
$scope.isLoaded = false;
// Bind upload folder data to user account on firebase
var refUploadFolder = new Firebase(FBURL.FBREF).child("/users/" + $rootScope.auth.user.uid + "/upload_folder");
$scope.upload_folder = $firebase(refUploadFolder);
$scope.upload_folder.$bind($scope,'upload_folder');
// default file picker options
$scope.defaults = {
mimetype: 'image/*',
multiple: true,
container: 'fpframe'
};
// make sure filepicker script is loaded before doing anything
// i.e. $scope.isLoaded can be used to display controls when true
(function chkFP() {
if ( window.filepicker ) {
filepicker.setKey(fpKey);
$scope.isLoaded = true;
$scope.err = null;
// additional picker only options
var pickerOptions = {
services:['COMPUTER', 'FACEBOOK', 'GMAIL']
};
var storeOptions = {
location: 'S3',
container: 'imagegrid'
};
var options = $.extend( true, $scope.defaults, pickerOptions );
// launch picker dialog
filepicker.pickAndStore(options, storeOptions,
function(InkBlobs){
uploadFiles.process(InkBlobs, $scope.upload_folder);
},
function(FPError){
$scope.err = FPError.toString();
}
);
} else {
setTimeout( chkFP, 500 );
}
})();
}])
I also have a service handling the input from Filepicker, this creates new entries in the firebase at the reference that is bound (using Firebase methods rather than AngularFire maybe this breaks the binding?)
.service('uploadFiles', ['$rootScope', 'FBURL', function($rootScope, FBURL) {
return {
process: function(InkBlobs, upload_folder) {
var self = this;
var countUpload = 0;
// write each blob to firebase
angular.forEach(InkBlobs, function(value, i){
var asset = {blob: value};
// add InkBlob to firebase one it is uploaded
upload_folder.$add(asset).then( function(ref){
self.getDetails(ref);
countUpload++;
});
});
// wait for all uploads to complete before initiating next step
(function waitForUploads() {
if ( countUpload === InkBlobs.length ) {
self.createThumbs(upload_folder, { multi: true, update: false, location: 'uploads' });
} else {
setTimeout( waitForUploads, 500 );
}
})();
},
getDetails: function(ref) {
// after InkBlob is safely stored we will get additional asset data from it
ref.once('value', function(snap){
filepicker.stat(snap.val().blob, {size: true, mimetype: true, filename: true, width: true, height: true},
function(asset) {
// get asset type and filetype from mimetype
var mimetype = asset.mimetype.split('/');
asset.type = mimetype[0].replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
asset.filetype = mimetype[1];
// add metadata to asset in upload folder
ref.update(asset);
});
});
},
createThumbs: function(ref, options) {
var self = this;
// default options
options.multi = options.multi || false;
options.update = options.update || false;
options.location = options.location || 'asset';
// if pathbase is not provided generate it based on provided location
if (!options.pathbase) {
if (options.location === 'assets') {
options.pathbase = FBURL.LIBRARY + "/assets/";
} else if (options.location === 'uploads') {
options.pathbase = "/users/" + $rootScope.auth.user.uid + "/upload_folder/";
} else {
throw new Error('SERVICE uploadFiles.createThumbs: options.location is not valid must be assets or uploads');
}
}
var generateThumb = function(blob, path) {
filepicker.convert( blob,
{ width: 200, height: 150, fit: 'crop' },
{ location: 'S3', access: 'public', container: 'imagegrid', path: '/thumbs/' },
function(tnInkBlob){
var refThumbBlob = new Firebase(FBURL.FBREF).child(path);
refThumbBlob.set(tnInkBlob);
},
function(FPError){
alert(FPError);
},
function(percentage){
// can use to create progress bar
}
);
};
if (options.multi) {
// look at all assets in provided ref, if thumbnail is mission or update options is true generate new thumb
angular.forEach(ref, function(value, key){
if (typeof value !== 'function' && (!value.tnblob || options.update)) {
// thumb doesn't exist, generate it
var blob = value.blob;
var path = options.pathbase + key + '/tnblob';
generateThumb(blob, path);
}
});
} else {
// getting thumbnail for a single asset
var refAsset = new Firebase(FBURL.FBREF).child(options.pathbase + ref);
var blob = refAsset.val().blob;
var path = options.pathbase + ref + '/tnblob';
generateThumb(blob, path);
}
}
};
}]);
So to recap, data is being saved to /users/$rootScope.auth.user.uid/upload_folder and this is being rendered in the HTML. Changes in the HTML form are reflected in the scope but not in Firebase, despite the binding:
var refUploadFolder = new Firebase(FBURL.FBREF).child("/users/" + $rootScope.auth.user.uid + "/upload_folder");
$scope.upload_folder = $firebase(refUploadFolder);
$scope.upload_folder.$bind($scope,'upload_folder');
Any ideas as to why this is? Is my implementation incorrect or am I somehow breaking the binding? Is $bind even supposed to work with ng-repeat in this manner?
Thanks
Shooting myself for how simple this is, the error was in how I defined the binding. You can't set the binding on itself, you need two separate objects in the scope...
The firebase reference $scope.syncdata loads the initial data and all modifications made to $scope.upload_folder will be synced to firebase.
var refUploadFolder = new Firebase(FBURL.FBREF).child("/users/" + $rootScope.auth.user.uid + "/upload_folder");
$scope.syncdata = $firebase(refUploadFolder);
$scope.syncdata.$bind($scope,'upload_folder');

Resources