Конечно, ожидается, что оно будет таким же, у вас есть только 1 свойство, которое обрабатывает дополнительную информацию, которая является $scope.childPar
, вместо того, чтобы манипулировать вашими данными, которые соответствуют вашему условию
Попробуйте это
function example() {
factor.getUse().then(function (response) {
//Remap the model, [data] -> user, [otherInfo] -> other info
var users = response.data.map(function(value) {
return { data: value, otherInfo: null }
});
$scope.users = users;
console.log($scope.users);
});
}
example();
$scope.togglePerson = function (index) {
factor.getChi().then(function (response) {
$scope.indx = index;
$scope.child = response.data;
console.log($scope.child);
//Populate the otherInfo from the response
$scope.users[index].otherInfo = response.data;
console.log($scope.childPar);
});
};
HTML
<div class="panel panel-default" style="background: #fcf8e3">
<div class="panel-body">
<table st-safe-src="leads" class="table table-hover ">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Last Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="user in users track by $index" ng-init="parentIndex=$index"
ng-click="togglePerson($index); viewChild=!viewChild ">
<td> {{user.data.id}}</td>
<td>{{user.data.name}}</td>
<td>{{user.data.lastName}}</td>
</tr>
<tr ng-show="viewChild" ng-hide="indx!=$index" >
<td style="width: 450px">
<table class="table ">
<tbody>
<tr>
<th style="width: 200px">
Address
</th>
<td style="width: 200px">{{user.otherInfo.address}}</td>
<th style="width: 200px">
Number
</th>
<td style="width: 200px">{{user.otherInfo.mobNumb}}</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr ng-repeat-end></tr>
</tbody>
</table>
</div>
</div>