gpt4 book ai didi

javascript - AngularJS - Bootstrap Material Datetimepicker 不工作

转载 作者:可可西里 更新时间:2023-11-01 15:00:58 24 4
gpt4 key购买 nike

我正在使用这个 datetimepicker对于我的 angularjs 项目。在 head 标签中包含 jquery、moment、datetimepicker。我的输入在 ng-repeat 中,我在 Controller 中初始化了 datetimepicker。但是,当我点击输入时它仍然没有显示。这是我的代码 -

HTML

<div class="numeric-type" ng-show="f.type == 'dateBased_filter'">
<input type="text" id="date">
</div>

JS

setTimeout(function(){
$('#date').bootstrapMaterialDatePicker({
format: 'D MMM YYYY',
year: true,
date: true,
time: false,
clearButton: true,
maxDate: moment()._d,
change: function(event, date){
console.log(event);
console.log(date);
}
});
},2000);

最佳答案

直接从 angularjs Material 组件检查此代码笔 https://codepen.io/anon/pen/rvQojz

文档 https://material.angularjs.org/latest/api/directive/mdDatepicker

html

<md-content ng-controller="AppCtrl as ctrl" layout-padding="" ng-cloak="" class="datepickerdemoBasicUsage" ng-app="MyApp">
<div layout-gt-xs="row">
<div flex-gt-xs="">
<h4>Standard date-picker</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date"></md-datepicker>
</div>

<div flex-gt-xs="">
<h4>Disabled date-picker</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date" disabled=""></md-datepicker>
</div>
</div>

<div layout-gt-xs="row">
<div flex-gt-xs="">
<h4>Opening the calendar when the input is focused</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date" md-open-on-focus=""></md-datepicker>
</div>

<div flex-gt-xs="">
<h4>Date-picker that goes straight to the year view</h4>
<md-datepicker ng-model="ctrl.myDate" md-current-view="year" md-placeholder="Enter date"></md-datepicker>
</div>
</div>

<div layout-gt-xs="row">
<div flex-gt-xs="">
<h4>Custom calendar trigger</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date" md-is-open="ctrl.isOpen"></md-datepicker>
<md-button class="md-primary md-raised" ng-click="ctrl.isOpen = true">Open</md-button>
</div>

<div flex-gt-xs="">
<h4>Date-picker that only allows for the month to be selected</h4>
<md-datepicker ng-model="ctrl.myDate" md-placeholder="Enter date" md-mode="month"></md-datepicker>
</div>
</div>
</md-content>

JavaScript

angular.module('MyApp', ['ngMaterial', 'ngMessages', 'material.svgAssetsCache']).controller('AppCtrl', function() {
this.myDate = new Date();
this.isOpen = false;
});

关于javascript - AngularJS - Bootstrap Material Datetimepicker 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50404692/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com