Home Is there a way to get Angular datepicker close on mouseleave?
Reply: 1

Is there a way to get Angular datepicker close on mouseleave?

Petroskali
1#
Petroskali Published in 2018-01-12 21:51:18Z

I have an angular calender that closes if clicked outside. However other things on my view close with ng-mouseLeave and Id like datepicker to act the same.

<datepicker date-format="d MMMM, yyyy">
   <input ng-class="{true: 'error-bron', false:'nonerror-bron' [dateError===true]" readonly="true" class="bron-date" ng-model="$root.date" type="text" placeholder="Pick a date"/>
</datepicker>

Ruchira Chamara
2#
Ruchira Chamara Reply to 2018-01-12 22:08:05Z

I would suggest you to use the following approach by creating a directive and then use it like the following.

angular.module('YOUR_APP').directive('documentHover', function ($document, $parse) {
    var linkFunction = function ($scope, $element, $attributes) {
       var scopeExpression = $attributes.documentHover,
           invoker = $parse(scopeExpression);
           $document.on('hover', function (event) {
           var targetElement = event.target;
           $('DATE_PICKER_CLASS').removeClass('show').addClass('hide');
           $scope.$apply(function () {
                  invoker($scope, { $event: event });
           });
       });
    };
    return linkFunction;
});
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.336239 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO