Javascript 使用Firebug进行角度调试
我正在制作一个AngularJS应用程序,它从Firebase云获取数据。数据显示在第页,但当我调试控制器时,它会显示一个空的文章列表。为什么调试期间我的变量显示为空 以下是我的控制器的代码:Javascript 使用Firebug进行角度调试,javascript,angularjs,firebase,firebug,firebase-realtime-database,Javascript,Angularjs,Firebase,Firebug,Firebase Realtime Database,我正在制作一个AngularJS应用程序,它从Firebase云获取数据。数据显示在第页,但当我调试控制器时,它会显示一个空的文章列表。为什么调试期间我的变量显示为空 以下是我的控制器的代码: appMainModule.controller('GetCtrl', ['$scope', '$firebaseArray', function ($scope, $firebaseArray) { var firebaseObj = new Firebase("URL") debugger;
appMainModule.controller('GetCtrl', ['$scope', '$firebaseArray', function ($scope, $firebaseArray) {
var firebaseObj = new Firebase("URL")
debugger;
//var sync = $firebaseArray(firebaseObj);
//$scope.articles = sync.$asArray();
$scope.articles = $firebaseArray(firebaseObj);
var firebaseObj1 = new Firebase("URL");
$scope.articles1 = $firebaseArray(firebaseObj1.orderByChild("Month").equalTo("Apr-2016"));
var query=$scope.articles1
var num = query.length;
}]);
这是我的HTML代码:
<div class="content" style="height: 380px; overflow: auto;">
<table class="table">
<thead>
<tr>
<th>Incident Name</th>
<th>Category</th>
<th>Month</th>
<th>Total</th>
</tr>
</thead>
<tbody ng-repeat="article in articles1 ">
<tr>
<td><p>{{article.IncidentName}}</p></td>
<td><p>{{article.CategoryParent}}</p></td>
<td><p>{{article.Month}}</p></td>
<td><p>{{article.Total}}</p></td>
</tr>
</tbody>
</div>
事件名称
类别
月
全部的
{{article.IncidentName}
{{article.CategoryParent}
{{article.Month}
{{article.Total}
在HTML页面中,
articles1
提供了数据,但在控制器中,在获取数据后,它显示为空。我解决了我的问题,我希望我的数据早在异步调用firebase时就出现了。下面是firebase返回数据承诺时的方法
$scope.articles1.$loaded(function(data){
// do here with data,what you want
})
我解决了我的问题,我希望我的数据很早就被异步调用到firebase。下面是firebase返回数据承诺时的方法
$scope.articles1.$loaded(function(data){
// do here with data,what you want
})