这是我的代码。我正在使用Angular Material。如何将日历设置为仅显示月份和年份?
<input matInput [matDatepicker]="picker" readonly>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker startView="year" [startAt]="startDate"></mat-datepicker>
答案 0 :(得分:1)
似乎这个功能最近添加了拉请求
您可以设置视图
this._activeDate = this._monthView ?
this._activeDate = this._currentView == 'month' ?
<强> PULL-REQUEST 强>
然而,通过将模式设置为
,可以使用angularjs-materialmd-mode="month"
答案 1 :(得分:1)
对于具有月份和年份的Angular Material日期选择器-
app.js
var app = angular.module('plunker', ['ngMaterial']);
app.controller('MainCtrl', function($scope) {
var monthFormat = buildLocaleProvider("MMM-YYYY");
function buildLocaleProvider(formatString) {
return {
formatDate: function (date) {
if (date) return moment(date).format(formatString);
else return null;
},
parseDate: function (dateString) {
if (dateString) {
var m = moment(dateString, formatString, true);
return m.isValid() ? m.toDate() : new Date(NaN);
}
else return null;
}
};
}
$scope.dateFields = [
{
type: 'date',
required: false,
binding: 'applicant.expectedGraduation',
startView: 'month',
label: 'Credit Card Expiry - Year/Month picker',
mode: 'month',
locale: monthFormat
}
];
});
index.html
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS material-sidenav Plunker</title>
<script>
document.write('<base href="' + document.location + '" />');
</script>
<link rel="stylesheet" href="https://static.formhero.io/formhero/js/material/v1.1.1-fh-build/angular-material.min.css">
<link rel="stylesheet" href="style.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script src="https://static.formhero.io/formhero/js/material/v1.1.1-fh-build/angular-material.min.js"></script>
<script src="app.js"></script>
</head>
<body layout="row" layout-wrap flex layout-fill layout-align="start start" ng-controller="MainCtrl">
<md-input-container flex="100" layout="column">
<div style="font-size: 10px; color: blue;" label ng-bind="::dateFields[0].label"></div>
<md-datepicker ng-model="dateFields[0].selectedDate"
ng-required="dateFields[0].required"
md-date-locale="dateFields[0].locale"
md-mode="{{dateFields[0].mode}}"
md-open-on-focus="true">
</md-datepicker>
</md-input-container>
</body>
</html>
要进行演示,请使用以下链接- https://plnkr.co/edit/zXhgq3?p=preview
答案 2 :(得分:-2)
Sajeetharan,
aux_dummy = np.zeros(shape=(AUX_FEATURE_VECTOR_SIZE,))
print(aux_dummy.shape)
print(aux_dummy)
q_vals, _ = model.predict([encode_1_hot(next_state), aux_dummy], batch_size=1)
如何使用这个,在角度5中使用json模式形式的mat-datepicker