Angular Js -moment Picker 时间插件(不需引用JQ)
一、使用插件首先下载引用。
npm install angular-moment-picker npm install moment
<link href="angular-moment-picker.css" rel="stylesheet"> <script src="angular.js"></script> <script src="moment-with-locales.js"></script> <script src="angular-moment-picker.js"></script> <script src="index.js"></script>
二、Html 页面
<input placeholder="Select a date..." moment-picker="ctrl.stringDate" format="YYYY-MM-DD" today="true" min-date='ctrl.MinDate' start-view="month" change="ctrl.onChange(newValue, oldValue)" ng-model="ctrl.momentDate">
三、Controller
angular .module('Demo', ['moment-picker']) .config(['momentPickerProvider', function (momentPickerProvider) { momentPickerProvider.options({ locale:"zh-cn", }); }]) .controller('DemoController', ['$scope', function () { var ctrl = this; ctrl.onChange = function (newValue, oldValue) { console.log(newValue._i); console.log(ctrl.stringDate); }; //最小值 ctrl.MinDate = moment().subtract(0, 'day'); }]);