【发布时间】:2018-07-18 23:04:32
【问题描述】:
您好,我目前正在我的两个文本框中输入日期时间选择器。
我想要做的是,在用户在第一个文本框中选择日期后,会弹出第二个文本框的日期时间选择器。用户无需点击第二个框。
这是我的代码。
html
<md-input-container>
<input time="true" date="true" mdc-datetime-picker type="text" id="date" placeholder="Start Date" ng-model="date">
</md-input-container>
<md-input-container>
<input time="true" date="true" mdc-datetime-picker type="text" id="date" placeholder="End Date" ng-model="date">
</md-input-container>
javascript
(function () {
'use strict';
angular
.controller('DemoCtrl_{{boundField.name}}', function ($scope, mdcDateTimeDialog) {
$scope.date = new Date('{{boundField.value()}}');
$scope.dateTime = new Date();
$scope.minDate = moment().subtract(1, 'month');
$scope.maxDate = moment().add(1, 'month');
$scope.displayDialog = function () {
mdcDateTimeDialog.show({
maxDate: $scope.maxDate,
time: false
})
.then(function (date) {
$scope.selectedDateTime = date;
console.log('New Date / Time selected:', date);
});
};
})
;
})();
我是 angularjs 的新手,尤其是 javascript 部分。非常感谢您的帮助。 :)
【问题讨论】:
-
如果你想让它成为标签,你可以对两个输入都做
tabindex="1" and tabindex="2" -
你可以试试 daterangepicker 这个功能。
-
您可以在指令的第一个文本框上绑定
input事件,然后将焦点移到第二个文本框上。 -
我相信这正是我所需要的。 @Jai,请您帮我解决一下绑定输入事件的代码以及如何将焦点移到第二个文本框?
标签: javascript angularjs angular-material angularjs-watch