簡體   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