I have a problem with ng-repeat:
Here is my html file
<body ng-app="TestApp" ng-controller="TestAppCtrl">
<button ng-repeat="value in array" class="btn btn-primary" ng-click="onclick($event)" id={{value}} >{{value}}</button>
<br>
<div class"btn-group" data-toggle="buttons">
<label ng-repeat="data in arrayToPrint track by $index " class="btn btn-primary">
<input type="checkbox" autocomplete="off" >{{data}}
</label>
</div>
</body>
Here is my controller:
angular.module('TestApp',[])
.controller('TestAppCtrl', function ($scope) {
$scope.array=["gps","meteo"];
var array1=["lat","lon"];
var array2=["airtemp","watertemp","pressure"];
$scope.onclick=function(event){
if(event.target.id=="gps"){
$scope.arrayToPrint=array1;
}else {
$scope.arrayToPrint=array2;
}
}
});
When I clic on the first button (gps), the array of button lat, lon appears.
I select lat button to make it active.
But my problem is when I clic on the second button (meteo) the first button is active.
I don't have the problem if I remove "track by $index" in my ng-repeat.
But I don't know why.