所有人。 我在視圖中加載數據時遇到問題。 我的控制器是從請求中檢索後,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>
在此視圖
任何人都可以幫助我。 在此先感謝
會發生什麼,如果你控制檯登錄按鈕的$ scope.mall_roakker_detail點擊?輸出是什麼? – Shayuh
請參閱控制檯輸出放在編輯的圖片 –
你也可以顯示整個html輸出..或者做一個plunker ..我問了什麼是console.log($ scope.mall_roakker_detail)以查看範圍是否獲取值.. 。 – Shayuh