【问题标题】:Is there a way to get Angular datepicker close on mouseleave?有没有办法让 Angular datepicker 在 mouseleave 上关闭?
【发布时间】:2018-01-12 21:51:18
【问题描述】:

我有一个角日历,如果在外面点击它就会关闭。然而,在我看来,其他事情与 ng-mouseLeave 和 Id 一样,就像 datepicker 一样。

<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>

【问题讨论】:

  • 从用户体验的角度来看,我建议您保持原样。

标签: angularjs datepicker


【解决方案1】:

我建议您通过创建指令来使用以下方法,然后像下面这样使用它。

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;
});

【讨论】:

    猜你喜欢
    • 2011-04-05
    • 2022-01-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多