HTML Markup:
<div ng-repeat="item in items">
<div class="dropdown-menu" ng-click=itemsActive()>click me</div>
<ul ng-show="itemVisible">
<li>item 1</li>
<li>item 2</li>
</ul>
</div>
Controller code:
$scope.itemVisible = false;
$scope.itemsActive = function(){
$scope.itemVisible = !$scope.itemVisible;
}
Above, is the markup where on ng-click I am calling a function itemsActive() and in controller I have a scope variable $scope.itemVisible = false. And, items dropdown is initially not shown by assigning ng-show = "itemVisible". So, onclick scope variable is toggled to true/false. But, since ng-repeat is used all repeated items 'dropdown-menu' divs are also getting toggled. How to achieve for a particular div show/hide ul items.
I edited my code HTML Markup:
<div ng-repeat="item in items">
<div class="dropdown-menu" ng-click="item.visible=!item.visible>"click me</div>
<ul ng-show="itemVisible">
<li>item 1</li>
<li>item 2</li>
</ul>
</div>
Now, on click, Item is toggled on/off. But, onclick of first item and second item the dropdown is visible. If I click on first item and click on second item then first item should be hidden?