【问题标题】:Angularjs: open on focus and month picker feature to calendar?Angularjs:打开日历的焦点和月份选择器功能?
【发布时间】:2016-12-17 00:11:17
【问题描述】:

如何将焦点打开功能(类似于 Microsoft Windows 7 日历)添加到我的日历中,如 demo 中给出的,我们使用 angular materiel version1.0.1,请帮助我解决问题。

Thanks In advance.

【问题讨论】:

  • 你能更新到 Angular Material 1.1.1 吗?如果是这样,您可以将 md-open-on-focus 指令添加到您的日期选择器。
  • 感谢回复,不更新 Angular 材料 1.1.1 怎么办?

标签: jquery angularjs angularjs-directive angularjs-scope


【解决方案1】:

在这种情况下,您必须添加自定义指令:

.directive('openOnFocus', function () {

  function compile(tElement) {
    tElement.find('input').attr('ng-focus', 'ctrl.onFocus($event)');

    return function (scope, element, attrs, datePicker) {
      var focused = false;

      datePicker.onFocus = (event) => {
        focused = !focused;

        if(focused) {
          datePicker.openCalendarPane(event);
        }
      };
    };
  }

  return {
    compile: compile,
    priority: -1,
    require: 'mdDatepicker',
    restrict: 'A'
  };
});

然后:

<md-datepicker open-on-focus></md-datepicker>

摘自此 github 评论:

https://github.com/angular/material/issues/4650#issuecomment-191930096

【讨论】:

  • 感谢您的尝试,请您指出它的工作示例。它没有按预期工作演示(plnkr.co/edit/dbR7K1bngMaF7iO4S09o?p=preview).. 日历图标必须是可点击的 1.1.1((material.angularjs.org/latest/demo/datepick‌​er))版本日历当我们点击( 2016 年 12 月)它提供了一年中的几个月并且很快......但你的演示没有?
  • 当您单击日历图标时,链接中的日历看起来像是在打开?不知道是什么问题
  • 为它添加了新问题stackoverflow.com/questions/41250474/…请看一下
猜你喜欢
  • 2017-02-25
  • 1970-01-01
  • 1970-01-01
  • 2021-10-27
  • 1970-01-01
  • 2016-12-02
  • 1970-01-01
  • 2019-05-04
  • 1970-01-01
相关资源
最近更新 更多