AngularJS dropdown directive hide when clicking outside

后端 未结 9 2081
长发绾君心
长发绾君心 2020-11-29 22:06

I\'m trying to create a multiselect dropdown list with checkbox and filter option. I\'m trying to get the list hidden with I click outside but could not figure it out how. A

9条回答
  •  [愿得一人]
    2020-11-29 22:52

    OK I had to call $apply() as the event is happening outside angular world (as per doc).

        element.bind('click', function(event) {
        event.stopPropagation();      
        });
    
        $document.bind('click', function(){
        scope.isVisible = false;
        scope.$apply();
        });
    

提交回复
热议问题