从请求中检索后,angularjs数据未显示在视图中

问题描述:

所有人。 我在视图中加载数据时遇到问题。 我的控制器是从请求中检索后,angularjs数据未显示在视图中

app.controller('AccountController', function(dataFactory,$scope,$http){ 
getResultsPage(1); 
function getResultsPage(pageNumber) { 

    if(! $.isEmptyObject($scope.libraryTemp)){ 
     if($.isEmptyObject($scope.searchText)){ 
     $scope.searchText = ''; 
     } 
     if($.isEmptyObject($scope.account_type)){ 
     $scope.account_type = ''; 
     } 
     dataFactory.httpRequest('/angular_project/public/accounts?search='+$scope.searchText+'&account_type='+$scope.account_type+'&page='+pageNumber).then(function(data) { 
     $scope.data = data.account.data; 
     $scope.accountType = data.account_type; 
     $scope.totalItems = data.account.total; 
     $scpoe.perpage = data.perpage; 
     }); 
    }else{ 
    dataFactory.httpRequest('/angular_project/public/accounts?page='+pageNumber).then(function(data) { 
     $scope.data = data.account.data; 
     $scope.accountType = data.account_type; 
     $scope.totalItems = data.account.total; 
     $scope.perpage = data.perpage; 
     console.log(data); 
    }); 
    } 
} 
$scope.accounts_detail = function(id){ 
    dataFactory.httpRequest('accounts_detail/'+id).then(function(data) {console.log(data); 
     $scope.sales_items_detail = data.sales_items_detail; 
     $scope.mall_roakker_detail = data.mall_roakker_detail; 
     $scope.transection_detail = data.transection_detail; 
     console.log($scope.sales_items_detail); 
     $scope.ddd = 'asdfasdf'; 
     //getResultsPage(1); 
    }); 
}  
}); 

我的第一个观点是:

<tbody> 
        <tr dir-paginate="value in data | itemsPerPage:perpage" total-items="totalItems"> 
         <td>{{ $index + 1 }}</td> 
         <td>{{ value.name }}</td> 
         <td>{{ value.address }}</td> 
         <td>{{ value.title }}</td> 
         <td>{{ value.check_from }}</td> 
         <td>{{ value.check_to }}</td> 
         <td> 
         <button data-toggle="modal" ng-click="edit(value.id)" data-target="#edit-data" class="btn btn-primary">Edit</button> 
         <a href="#/accounts_detail" class="btn btn-success" ng-click="accounts_detail(value.id)">Account Detail</a> 

         </td> 
        </tr> 
       </tbody> 

的问题是,当我点击通过,但就是相关视图不显示从数据库加载帐户资料的链接数据。

<div class="row"> 
<div class="col-md-12"> 
    <div class="card"> 
     <div class="card-header" data-background-color="purple"> 
      <h4 class="title">Account Detail</h4> 

     </div>     
     <div class="card-content table-responsive"> 
      <table class="table table-bordered pagin-table"> 
       <thead> 
        <tr> 
         <th>Name</th> 
         <th>Item Name</th> 
         <th>Rate</th> 
         <th>Weight</th>        
        </tr> 
       </thead> 
       <tbody> 
        <tr ng-repeat="x in mall_roakker_detail"> 
         <td>{{ x.name }}</td> 
         <td>{{ x.title }}</td> 
         <td>{{ x.rate }}</td> 
         <td>{{ x.weight }}</td>        
        </tr> 
       </tbody> 
       <tfoot> 

       </tfoot> 
      </table> 

     </div> 
    </div> 
</div> 

在此视图

,数据没有显示,但控制台显示此数据。 enter image description here

任何人都可以帮助我。 在此先感谢

+0

会发生什么,如果你控制台登录按钮的$ scope.mall_roakker_detail点击?输出是什么? – Shayuh

+0

请参阅控制台输出放在编辑的图片 –

+0

你也可以显示整个html输出..或者做一个plunker ..我问了什么是console.log($ scope.mall_roakker_detail)以查看范围是否获取值.. 。 – Shayuh

我认为在您的js文件中您的$scope.accounts_detail = function (id){}不从任何地方拨打电话。 调用这个函数像

$scope.accounts_detail(id); 
+0

我在这里调用这个函数Detail

+0

你可以创建一些plunker或小提琴吗? – Dixit