I created this fiddle exclusively to adress my problem. I am ng-repeat
ing certain section. I have a toggle functionality to be implemented inside it. However, when I click the button, function gets triggered for all the repeated items. This works fine when not using ng-repeat
inspite of using the same function name on click. Below is the code. I guess there is something like the this
operator that I can make use here. My code so far (I created this for the fiddle and not the original),
HTML
<div ng-app="app">
<div ng-controller="CommentController">
<div ng-repeat="list in lists">
<button ng-click="showDiv()" class="review">{{lists[$index]}}</button>
<div ng-show="hiddenDiv">This is the div to be toggled on clicking any of the above button. And they do so as they make use of <i>same function on click.</i>
</div>
</div>
</div>
</div>
controller
var app = angular.module('app', []);
app.controller('CommentController', function ($scope) {
$scope.hiddenDiv = true;
$scope.showDiv = function () {
$scope.hiddenDiv = !$scope.hiddenDiv;
};
$scope.lists = ["one", "two", "three", "four", "five"];
});