本文将带您了解关于使用angularjs封装bootstrapdatetimepicker选择日期时间的新内容,同时我们还将为您解释angularjs日期控件的相关知识,另外,我们还将为您提供关于20
本文将带您了解关于使用angularjs封装bootstrap datetimepicker选择日期时间的新内容,同时我们还将为您解释angularjs日期控件的相关知识,另外,我们还将为您提供关于2021/09/05 bootstrap 日期时间戳 datetimepicker、AngularJS / Angular-ui-bootstrap更改datePicker使用的语言、angularjs – Angular bootstrap datepicker日期格式不格式ng-model值、angularjs – Angular Bootstrap datepicker自定义类的实用信息。
本文目录一览:- 使用angularjs封装bootstrap datetimepicker选择日期时间(angularjs日期控件)
- 2021/09/05 bootstrap 日期时间戳 datetimepicker
- AngularJS / Angular-ui-bootstrap更改datePicker使用的语言
- angularjs – Angular bootstrap datepicker日期格式不格式ng-model值
- angularjs – Angular Bootstrap datepicker自定义类
使用angularjs封装bootstrap datetimepicker选择日期时间(angularjs日期控件)
// 1.引入相关的JS和css
// 2.封装指令
/**
* http://www.bootcss.com/p/bootstrap-datetimepicker/
* 时间日期组件
* minView: 2, 设置只能选日期
* format: 格式化日期-> yyyy-mm-dd yyyy-mm-dd hh:ii yyyy-mm-dd hh:ii:ss
* initialDate: 初始化日期
*/
utilModule.directive("gDatetimepicker", function($timeout) {
return {
restrict: ''EA'',
scope: {
gFormat: "@",
gOpenTime: "@"
},
link: function($scope,element,attrs) {
if (angular.isUndefined($scope.gOpenTime)) {
$scope.gOpenTime = ''true'';
}
// 没有开启时间,并且没有输入格式化
if ($scope.gOpenTime == ''false'' && angular.isUndefined($scope.gFormat)) {
$scope.gFormat = "yyyy-mm-dd";
}
if (angular.isUndefined($scope.gFormat)) {
$scope.gFormat = "yyyy-mm-dd hh:ii";
}
$timeout(function(){
$(element).datetimepicker({
language: datetimePickerI18N, // datetimePickerI18N在jspHeader.jsp定义的
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
showMeridian: 1,
minView: $scope.gOpenTime == ''false'' ? 2 : 0,
autoclose: 1,
format: $scope.gFormat
});
},500);
}
}
});
//3.在页面中使用
<!-- 不开启选择时间 -->
<input type="text" g-datetimepicker g-open-time="false" />
<!-- 开启 -->
<input type="text" g-datetimepicker />
2021/09/05 bootstrap 日期时间戳 datetimepicker
–背景:使用CDN引入
–控件效果(可选时分秒)
–代码
html
<div>
<div>
<divcol-sm-2''>
<div>
<divinput-group date'' id=''datetimepicker1''>
<input type=''text''/>
<span>
<span></span>
</span>
</div>
</div>
</div>
</div>
</div>
js
<script src="https://cdn.bootcss.com/moment.js/2.18.1/moment-with-locales.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
//写在方法里面
$(''#datetimepicker1'').datetimepicker();//初始化datetimepicker控件
获取控件选中的时间值(参考最后的参考链接2)
//获取datetimepicker数据
var datetime1 = $(''#datetimepicker1'').data().date;//没有数据时undefined
// console.log(''datetime1------------'', datetime1);
var datetimestamp = Date.parse(datetime1).toString();//毫秒时间戳
// console.log(''datetimestamp------'', datetimestamp);
var dts = datetimestamp.substr(0, datetimestamp.length - 3);//秒时间戳
// console.log(''dts'', dts);
–参考链接
1.datatimepick效果demo
2.通过控件获取时间戳
3.获取起始时间戳
总结
以上是小编为你收集整理的2021/09/05 bootstrap 日期时间戳 datetimepicker全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
原文地址:https://blog.csdn.net/Nighsloth/article/details/120114415
AngularJS / Angular-ui-bootstrap更改datePicker使用的语言
我使用记录的日期选择在这里。
但是,没有直接选项允许更改语言,默认情况下为 英语 。
我找到了不带angular指令提供的小部件的文档,它提供了一种实现它的好方法:
http://bootstrap-
datepicker.readthedocs.org/en/latest/i18n.html
有没有一种简便的方法来避免调整原始指令的源代码来进行更改?
答案1
小编典典如果您使用的是DatePicker表单angular-ui,只需在页面标题中添加本地化的js文件。一个例子是:
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js"></script><script src="http://code.angularjs.org/1.0.8/i18n/angular-locale_fr-fr.js"></script><script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script>
您可以在这里看到正在工作的矮人
angularjs – Angular bootstrap datepicker日期格式不格式ng-model值
"2009-02-03T18:30:00.000Z"
代替
02/04/2009
我为同一个plunkr link创建了一个plunkr
我的Html和控制器代码如下
<!doctype html> <html ng-app="plunker"> <head> <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script> <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js"></script> <script src="example.js"></script> <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <div ng-controller="DatepickerDemoCtrl"> <pre>Selected date is: <em>{{dt | date:'MM/dd/yyyy' }}</em></pre> <p>above filter will just update above UI but I want to update actual ng-modle</p> <h4>Popup</h4> <div> <div> <p> <input type="text"datepicker-popup="{{format}}" ng-model="dt" is-open="opened" min-date="minDate" max-date="'2015-06-22'" datepicker-options="dateOptions" date-disabled="disabled(date,mode)" ng-required="true" close-text="Close" /> <span> <button type="button"ng-click="open($event)"> <i></i></button> </span> </p> </div> </div> <!--<div> <div> <label>Format:</label> <selectng-model="format" ng-options="f for f in formats"><option></option></select> </div> </div>--> <hr /> {{dt}} </div> </body> </html>
角控制器
angular.module('plunker',['ui.bootstrap']); var DatepickerDemoCtrl = function ($scope) { $scope.open = function($event) { $event.preventDefault(); $event.stopPropagation(); $scope.opened = true; }; $scope.dateOptions = { formatYear: 'yy',startingDay: 1 }; $scope.format = 'dd-MMMM-yyyy'; };
感谢提前审查我的问题。
更新
我调用下面的方法发布我的数据,VAR是大小为900的数组,其中包含日期选择器变量。
public SaveCurrentData(formToSave: tsmodels.ResponseTransferCalculationModelTS) { var query = this.EntityQuery.from('SaveFormData').withParameters({ $method: 'POST',$encoding: 'JSON',$data: { VAR: formToSave.VAR,X: formToSave.X,CurrentForm: formToSave.currentForm,} }); var deferred = this.q.defer(); this.manager.executeQuery(query).then((response) => { deferred.resolve(response); },(error) => { deferred.reject(error); }); return deferred.promise; }
angular.module('yourAppName') .directive('datepickerPopup',function (){ return { restrict: 'EAC',require: 'ngModel',link: function(scope,element,attr,controller) { //remove the default formatter from the input directive to prevent conflict controller.$formatters.shift(); } } });
我在Github AngularUI issues找到了这个解决方案,因此所有的信用到那里的人。
angularjs – Angular Bootstrap datepicker自定义类
HTML
<uib-datepicker custom-ng-model="dt" min-date="minDate" show-weeks="false" starting-day="1"ng-change="selectDateChange()"></uib-datepicker>
JS
$scope.getDayClass = function (date,mode) { if ($scope.myCalendarEvents.length > 0) { if (mode === 'day') { var daytocheck = new Date(date).setHours(0,0); for (var i = 0; i < $scope.myCalendarEvents.length; i++) { var currentDay = new Date($scope.myCalendarEvents[i].startDate).setHours(0,0); if (daytocheck === currentDay) { return "full"; } } } return ''; } };
查看异步调用的示例(ps.这不是我的Plnkr):
http://plnkr.co/edit/h8PxWfxSEtZuVCct00mD?p=preview
解决方法
“variable”应该是myCalendarEvents,当显示uib-datepicker时,数据可用
关于使用angularjs封装bootstrap datetimepicker选择日期时间和angularjs日期控件的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于2021/09/05 bootstrap 日期时间戳 datetimepicker、AngularJS / Angular-ui-bootstrap更改datePicker使用的语言、angularjs – Angular bootstrap datepicker日期格式不格式ng-model值、angularjs – Angular Bootstrap datepicker自定义类等相关内容,可以在本站寻找。
本文标签: