-1

I am having one button - ON tapping on button, we are showing drop-down list On tapping of list item, I am making item's visibility false I want to hide button when all items are invisible And show button if we have a single item visible from list

I have tried this - [Please suggest some simplified code if you are having]

I am calling some function on click in which I am doing this - I am running a loop of list items from which I am taking number of invisible items ... And once my invisible item's length is similar to my actual list length, I am hiding the button .. So once I get a single item visible, my button will get shown

Curious_k.shree
  • 990
  • 2
  • 18
  • 37
  • Are you looking for something similar to a select? – Jaseem Abbas Jun 07 '16 at 06:04
  • What have you done so far? – Charlie Jun 07 '16 at 06:05
  • How you showing item? – RIYAJ KHAN Jun 07 '16 at 06:07
  • I have tried this : I am calling some function on click in which I am doing this - I am running a loop of list items from which I am taking number of invisible items ... And once my invisible item's length is similar to my actual list length, I am hiding the button .. So once I get a single item visible, my button will get shown – Curious_k.shree Jun 07 '16 at 06:23
  • @Curious_k.shree so, you have a working solution. What's the problem then? – JB Nizet Jun 07 '16 at 06:27
  • I want to use filters to make it simplified if any other way is there – Curious_k.shree Jun 07 '16 at 06:29
  • A filter is not really an appropriate solution for this problem, IMO. But you could use `ng-show="hasVisibleItem()"`, and define this function in the scope as `return items.some(function(item) { return item.visible; });`. – JB Nizet Jun 07 '16 at 06:51

1 Answers1

0

I have done it successfully with the help of .$filter

var filterLength = $filter('filter')(gloabalFilterOptions, { isVisible: true }).length;
        if (filterLength > 0) {
            $scope.showFilterLabel = true;
        } else {
            $scope.showFilterLabel = false;
        }
Curious_k.shree
  • 990
  • 2
  • 18
  • 37