I am trying to get a dynamic id to my array(details) within my ng-repeat so that I can bind to different data with different view of child div. Let me show an example.
<div class="row">
<div class="panel-heading bgOrg col-xs-12 col-sm-12 col-md-12 col-lg-12 header-container ">
<div class="col-sm-1 col-xs-12 pull-left "></div>
<div class="col-sm-1 col-xs-12 header-cell">Request# </div>
<div class="col-sm-1 col-xs-12 header-cell ">Id</div>
</div>
<div ng-repeat="data in friends">
<div class="row panel panel-body ">
<div class="col-xs-1">
<div class="handpointer glyphicon glyphicon-plus"
data-ng-click="collapse($event, data.id)"
data-target="#view_{{data.id}}"
data-toggle="collapse" aria-expanded="false">
</div>
</div>
<div class="col-sm-1 col-xs-12" data-ng-bind="data.requestId"></div>
<div class="col-sm-1 col-xs-12" data-ng-bind="data.id"></div>
</div>
<div class="collapse" id="view_{{data.id}}">
<div class="col-sm-offset-1">
<table class="table-condensed responsive-table">
<tr class="row">
<th><input class='header-checkbox' type='checkbox' /> </th>
<th>Id</th>
<th>Instance</th>
</tr>
<tr class="row" ng-repeat=" item in details[{{data.id}}]">
<td><input class='header-checkbox' type='checkbox' /></td>
<td data-ng-bind="item.id"></td>
<td data-ng-bind="item.name"></td>
</tr>
</table>
</div>
</div>
</div>
</div>
My problem is when I click on my parent div, I want to map child div with new data, Is it possible to set a dynamic ID in this concept?
Js:
$scope.details = [];
$scope.collapse = function (event, requestId) {
var deferred = $q.defer();
var idx = 0;
service.getDetail(requestId)
.then(function (response) {
$scope.details[requestId] = response;
deferred.resolve();
}, function (error) {
console.log(error);
deferred.reject();
});
return deferred.promise;
}
};