This is my angular code.. (to describe the problem I'm getting is that the nested ng-repeat for buttons repeats is behavior (when clicked) to all the "jobs" listed..
<div class="row" ng-repeat="job in jobs">
<div class="btn-group btn-group-justified" role="group">
<div class="btn-group" role="group" ng-repeat="status in job.statuscollection">
<button type="button" class="btn btn-default" ng-class="{ 'btn-info': $index == selectedIndex }" ng-click="itemClicked($index)">{{status.name}}</button>
</div>
</div>
</div>
Here's my js code..
$scope.jobs = [
{
_id: new Date().toISOString(),
statuscollection: [
{ name: "Off-Site"},
{ name: "Enroute" },
{ name: "On-Site" },
]
docType: "job",
},
{
_id: new Date().toISOString(),
statuscollection: [
{ name: "Off-Site"},
{ name: "Enroute" },
{ name: "On-Site" },
]
docType: "job",
}];
This here's my ng-click function..
$scope.itemClicked = function ($index) {
$scope.selectedIndex = $index;
console.log($scope.jobs[$index]);
}
I have more than just one job, I included only one here into the code to have less of it. but when the browser generates this data in the correct way, clicking on one of the "job's" buttons does the same thing for each job.
Meaning, if I click the button "on-site" for one job, it is duplicated for all the jobs.. how can I make it so that clicking just one of the job's buttons does it only for that job, and not all of them?