I have few div for onclick and few div to show it once onclick,but I want to show only specific div related to particular div.Here my application is working fine,but for 2 different section its repeating,if I click first once fourth div also showing.I have given different function also.Can anyone help me,I am new to angularjs. Below is the code.
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.11/angular.min.js"></script>
<script src="app.js"></script>
<body ng-app="plunker" ng-controller="MainCtrl">
<div ng-repeat="item in items">
<div style="color:red" ng-click="onClick1($index,0)">first</div>
<div style="color:blue" ng-show="div_[$index+'_0']">yyy</div>
<br />
<hr />
</div>
<div ng-repeat="item in items2">
<div style="color:red" ng-click="test($index,0)">second</div>
<p style="color:blue" ng-show="div_[$index+'_0']">zzz</p>
<br />
<hr />
</div>
</body>
app.js
angular.module('plunker', [])
.controller('MainCtrl', function($scope) {
$scope.div_=[];
$scope.items = [
{
// id: 1,
title: "first item"
},
{
// id: 2,
title: "second item",
},
{
// id: 3,
title: "third item",
}
];
$scope.items2 = [
{
id: 5,
title: "first item 1"
},
{
id: 6,
title: "second item 2",
},
{
id: 7,
title: "third item 3",
}
];
$scope.onClick1 = function (indexa, row1){
alert('first');
$scope.div_[indexa+'_'+row1]=true;
}
$scope.test = function (indexb, row2){
$scope.div_[indexb+'_'+row2]=true;
}
});