I am having problems accessing data downloaded from firebase using a method. $ on in AngularFire 0.5.0
There is data in the callback when I exit the contents of the data area, but when I try to use deeper data, I get undefined. Perhaps I do not understand how you want to access data in this method?
This is my controller:
.controller('AssetDetailCtrl',
['$scope', '$firebase', 'FBURL',
function($scope, $firebase, FBURL) {
var refAsset = new Firebase(FBURL + '/assets/' + $scope.assetId);
$scope.asset = $firebase(refAsset);
$scope.asset.$on('loaded', function() {
console.log($scope.asset);
console.log($scope.asset.name);
});
}])
So there may be a better way to do this.
Why can't I access data from the area, even if it is part of the console?
This is the result of the first console.log
Object { $bind: function, $add: function, $save: function, $set: function, $remove: function…}
$add: function (b,c){var d;return d="object"==typeof b?a._fRef.ref().push(a._parseObject(b),c):a._fRef.ref().push(b,c)}
$bind: function (b,c){return a._bind(b,c)}
$child: function (b){var c=new AngularFire(a._q,a._parse,a._timeout,a._fRef.ref().child(b));return c.construct()}
$getIndex: function (){return angular.copy(a._index)}
$on: function (b,c){switch(b){case"change":a._onChange.push(c);break;case"loaded":a._onLoaded.push(c);break;default:throw new Error("Invalid event type "+b+" specified")}}
$remove: function (b){b?a._fRef.ref().child(b).remove():a._fRef.ref().remove()}
$save: function (b){b?a._fRef.ref().child(b).set(a._parseObject(a._object[b])):a._fRef.ref().set(a._parseObject(a._object))}
$set: function (b){a._fRef.ref().set(b)}
asset_author: Object
collections: Array[2]
creator: "John Doe"
desc: "a description of the asset"
file: "http://lorempixel.com/400/200/sports/3/"
filesize: "28kb"
filetype: "jpg"
name: "Cycling"
release: "12/12/2013"
tags: "tag1, tag3"
type: "Photography"
__proto__: Object
The second .log console returns undefined