AngularJS dropdown directive hide when clicking outside

后端 未结 9 2124
长发绾君心
长发绾君心 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:58

    Use angular-click-outside

    Installation:

    bower install angular-click-outside --save
    npm install @iamadamjowett/angular-click-outside
    yarn add @iamadamjowett/angular-click-outside
    

    Usage:

    angular.module('myApp', ['angular-click-outside'])
    
    //in your html
    
    
    //And then in your controller
    $scope.closeThis = function () {
        console.log('closing');
    }
    

提交回复
热议问题