如何将打开焦点功能(类似于 Microsoft Windows 7 日历)添加到我的日历中,如 demo 中所示,我们使用 Angular Material 版本 1.0.1,请帮助我解决方案。
Thanks In advance.
在这种情况下,您必须添加自定义指令:
.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