【发布时间】:2015-12-19 02:05:14
【问题描述】:
我正在开发我的应用程序,我希望下拉值自动与日期选择器中的选定日期具有相同的值。我正在使用 angularjs,但我找不到足够的资源来专门回答我的问题。谢谢
这里有一些代码。我的整个代码都在 plunker 上
script type="text/ng-template" id="custom-datepicker.html">
<div class="form-inline enhanced-datepicker">
<label>
<input
type="text"
id="{{id}}"
name="{{name}}"
ng-model="ngModel"
datepicker-popup="{{popup}}"
datepicker-options="{{options}}"
date-disabled="{{dateDisabled}}"
min="{{min}}"
max="{{max}}"
open="opened"
ng-pattern="/^(?:[1-9]|1\d|2\d|3[0-1]) (?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec) (?:1|2)(?:\d{3})$/gim"/>
<span class="input-group-btn">
<button class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</label>
</div>
</script>
<script>
angular
.module('App',['ui.bootstrap'])
.directive('customDatepicker',function($compile,$timeout){
return {
replace:true,
templateUrl:'custom-datepicker.html',
scope: {
ngModel: '=',
dateOptions: '@',
dateDisabled: '@',
opened: '=',
min: '@',
max: '@',
popup: '@',
options: '@',
name: '@',
id: '@'
},
link: function($scope, $element, $attrs, $controller){
}
};
})
这里是 plunker 链接:http://plnkr.co/edit/4XRjszIATgvUVrofgRFI?p=preview
【问题讨论】:
标签: javascript jquery angularjs datepicker dropdown