<table ng-table="tableParams" show-filter="true" class="table">
<tr ng-repeat-start="user in $data">
<td data-title="'Patient'" filter="{ 'Patient': 'text' }" ng-click="getPatientDetails(user.RequestNumInt)">
{{user.Patient}}
</td>
</tr>
<tr ng-repeat-end>
<td>
<ul ng-hide="showDetails">
<li >
<table class="table">
<tr ng-repeat="exam in exams">
<td >{{exam.ExamName}}</td>
</tr>
</table>
</li>
</ul>
</td>
</tr>
</table>
$scope.getPatientDetails = function(RequestNumInt){
this.showDetails = this.showDetails === false ? true: false;
$http.get("api/controllers/LaboratoryController.php?RequestNumInt="+RequestNumInt).success(function(data){
$scope.exams=data;
});
};
$http({
method: 'GET',
url: 'api/controllers/LaboratoryController.php',
params: {'Cornum':232999}
}).success(function(response) {
var data = response;
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 50, // count per page
filter: {
// initial filter
}
}, {
total: data.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.filter() ?
$filter('filter')(data, params.filter()) :
data;
$scope.users = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve($scope.users);
}
});
});
<table ng-table="tableParams" show-filter="true" class="table">
<tr ng-repeat-start="user in $data">
<td data-title="'Patient'" filter="{ 'Patient': 'text' }" ng-click="getPatientDetails(user.RequestNumInt)">
{{user.Patient}}
</td>
</tr>
<tr ng-repeat-end>
<td>
<ul ng-show="detailsUserId === user.RequestNumInt">
<li >
<table class="table">
<tr ng-repeat="exam in exams">
<td >{{exam.ExamName}}</td>
</tr>
</table>
</li>
</ul>
</td>
</tr>
</table>
$scope.getPatientDetails = function(RequestNumInt){
$scope.detailsUserId = $scope.detailsUserId === RequestNumInt ? null : RequestNumInt;
$http.get("api/controllers/LaboratoryController.php?RequestNumInt="+RequestNumInt).success(function(data){
$scope.exams=data;
});
};
this.showDetails = this.showDetails === false ? true: false;
$scope.exams=data;
$scope.getPatientDetails = function(user){
user.$showDetails = user.$showDetails === false ? true: false;
$http.get("api/controllers/LaboratoryController.php?RequestNumInt="+user.RequestNumInt).success(function(data){
user.$exams=data;
});
};
$scope.getPatientDetails = function(user){
if (!user.$showDetails){
$http.get("api/controllers/LaboratoryController.php?RequestNumInt="+user.RequestNumInt).success(function(data){
user.$showDetails = true;
user.$exams=data;
console.log(user.$exams);
});
} else {
user.$showDetails = false;
}
};