使用push来更新angularjs和ionic中的视图

时间:2017-05-19 11:47:11

标签: javascript angularjs ionic-framework

我正在尝试在我的视图页面上显示搜索结果,但即使我在控制台中看到结果,结果也不会显示在视图中。

JS

.controller('statement_ctrl',['$scope','$http','$ionicLoading','$ionicPopup','$cordovaToast','$location','$ionicModal',function($scope,$http,$ionicLoading,$ionicPopup,$cordovaToast,$location,$ionicModal){
    $scope.username=localStorage.getItem("username");
    $scope.statement=[]

    $scope.request= function(){
    $ionicLoading.show({template: '<p>Processing Request...</p><ion-spinner></ion-spinner>'});
        event.preventDefault();
        $http.post('http://localhost/data/templates/statements/get.php?sdate='+$scope.sdate + '&edate=' + $scope.edate ).success
        (function(data){
       console.log(JSON.stringify(data));
       $scope.statement.push(data);
        });
        {$ionicLoading.hide();}
  }
        }])

HTML

<ion-view>
<ion-content ng-controller="statement_ctrl">
<div class="list">
  <label class="item item-input">
    <input type="text" placeholder="Search From" ng-model="sdate">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Search To" ng-model="edate">
  </label>
</div>
<div align="center">
<button class="button button-positive" ng-click="request()">
  <i class="icon ion-android-search icon"></i> Search
</button>
</div>
<div ng-repeat="item in statement track by $index">
  <table width="100%" border="0" cellspacing="4" cellpadding="4">
    <tr>
      <td><div align="center"><strong>Invoice ID</strong></div></td>
      <td><div align="center"><strong>Bill Period</strong></div></td>
      <td><div align="center"><strong> Balance</strong></div></td>
    </tr>
    <tr>
      <td><div align="center">{{item.invoice_number}}</div></td>
      <td><div align="center">{{item.bill_period}}</div></td>
      <td><div align="center">GH¢ {{item.current_balance}}</div></td>
    </tr>
  </table>
</div>
</ion-content>
</ion-view>

当我点击搜索按钮时,页面上没有任何内容

0 个答案:

没有答案