Reputation: 1182
I have made a datetime picker directive
adocsModule.directive('dateTimePicker', ['$timeout', function ($timeout) {
return {
link: function (scope, element, attrs, ctrl) {
$timeout(function () {
element.datetimepicker({
//language: 'fr',
weekStart: 1,
todayBtn: 1,
autoclose: 1,
todayHighlight: 1,
startView: 2,
forceParse: 0,
showMeridian: 1
});
}, 10);
scope.$apply();
}
}
}]);
i have used this directive in html, its working fine but the issue is when i set the value by datetime picker, it never update the ng-model attribute. i got permision.dateFrom empty in controller. Please help me
<div ng-show="permission.showDuration">
<div class="form-group margin-left-20px margin-top-5px">
<input type="text" date-time-picker class="form-control font-11px input-style1" placeholder="Select date from" ng-model="permission.fromdate" >
</div>
<div class="form-group margin-left-20px margin-top-5px">
<input type="text" date-time-picker class="form-control font-11px input-style1" placeholder="Select date from" ng-model="permission.todate">
</div>
</div>
Upvotes: 0
Views: 1888
Reputation: 1286
i once used datetime and this how i fixed
.on('changeDate', function (ev) {
$parse(attrs.ngModel).assign(scope, ev.date);
scope.$apply();
});
you need to parse the attribute and then assign its value to model, and apply changes
Upvotes: 1