md-select-close on click close md-select

0
381

In angularJs when we are using md-select on MODAL when we are using then autoclose is not working here is the solution :-


<div class="modal fade add-pop-form md-select-close" id="modalOpen" role="dialog">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="body-middle-part">
                </div>
            </div>
        </div>
    </div>
</div>

var dialogContainer = angular.element(document.querySelector('.md-select-close')),      
mdSelects = document.getElementsByTagName('md-select');     
dialogContainer.bind('click', function (event) {        
    var closeMdSelect = true;       
    angular.forEach(mdSelects, function (mdSelect) {        
        mdSelect = angular.element(mdSelect);       
            // what I do here is to check if the click event was triggered by the md-select I want to close. When opening the md-select, it will automatically close it, so I make sure that whenever this md-select is clicked, I don't hide it.       
            if (mdSelect.is(event.target) || mdSelect.has(event.target).length != 0) {      
                closeMdSelect = false;      
                return false;       
            }       
        });     
    if (closeMdSelect) {        
        $mdSelect.hide();       
    }       
});

LEAVE A REPLY

Please enter your comment!
Please enter your name here