Angularjs:关注焦点和月份选择器功能到日历?

时间:2016-12-17 00:11:17

标签: jquery angularjs angularjs-directive angularjs-scope

如何在demo中使用angular materiel version1.0.1添加焦点功能(类似于Microsoft Windows 7日历)添加到我的日历中,请帮我解决。

Thanks In advance.

1 个答案:

答案 0 :(得分:0)

在这种情况下你必须添加一个自定义指令:

.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