我已尝试使用md-blur
md-focus
,每次都失败了。我使用Angular Material 1.1.3
并且我需要在采取日期的操作后保持datepicker打开。所以,在这个动作之后如何保持打开状态。有人可以帮忙吗?
答案 0 :(得分:1)
由于md-datepicker documentation你无法做到这一点。 ngMaterials很好,但有很多限制。您可以使用此runnable demo codepen中的md-calendar
来“伪造”此内容。
<div ng-app="MyApp" ng-controller="MyController" layout-padding>
{{ date }}<br />
<input type="date" ng-model="date" ng-click="openDatePicker()" ng-show="!datePickerOpened">
<md-calendar class="fixed-calendar" ng-show="datePickerOpened" ng-model="date"></md-calendar>
</div>
.fixed-calendar {
width: 340px;
height: 340px;
display: block;
}
.fixed-calendar .md-calendar-scroll-mask {
width: 340px !important;
}
.fixed-calendar .md-virtual-repeat-scroller {
width: 340px !important;
height: 308px;
}
angular
.module('MyApp', ['ngMaterial'])
.controller('MyController', function($scope, $timeout) {
//Init
$scope.datePickerOpened = false;
$scope.date = new Date();
//show datepicker action
$scope.openDatePicker = function () {
//show datepicker
$scope.datePickerOpened = true
//avoid date set to 1933 by async reinit date after ng-show rendering
$timeout(function () {
$scope.date = new Date();
});
}
});