繁体   English   中英

使用Firebug进行角度调试

[英]Angular debugging using Firebug

我正在制作一个AngularJS应用程序,它从Firebase云中获取数据。 数据显示在页面上,但是当我调试我的控制器时,它显示了一个空的文章列表。 为什么我的变量在调试期间显示为空?

这是我的控制器的代码:

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>      

在HTML页面中, articles1提供数据,但在控制器内,它在获取数据后显示为空。

我解决了我的问题,我期待我的数据,因为它是对firebase的异步调用。 所以这是firebase返回数据承诺的方法

$scope.articles1.$loaded(function(data){
// do here with data,what you want
})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM