我无法使用AngularFire 0.5.0中的.$ on方法访问从firebase加载的数据
在回调当我注销范围的内容时,数据就在那里,但当我尝试使用更深入的数据时,我得到了undefined.也许我误解了你如何访问这种方法中的数据?
这是我的控制器:
.controller('AssetDetailCtrl',
['$scope', '$firebase', 'FBURL',
function($scope, $firebase, FBURL) {
var refAsset = new Firebase(FBURL + '/assets/' + $scope.assetId);
$scope.asset = $firebase(refAsset);
// when data is loaded check validity of the route
$scope.asset.$on('loaded', function() {
console.log($scope.asset); // complete with the asset data
console.log($scope.asset.name); // undefined even though it appears in the above console log
});
}])
Run Code Online (Sandbox Code Playgroud)
所以也许有更好的方法来做到这一点.
为什么即使它登录到控制台,我也无法访问范围内的数据?
这是第一个console.log的结果
Object { $bind: function, $add: function, $save: function, $set: function, $remove: function…}
$add: function (b,c){var d;return …Run Code Online (Sandbox Code Playgroud)