diosney / angular-bootstrap-datetimepicker-directive

A wrapper directive around the bootstrap-datetimepicker component.
MIT License
69 stars 50 forks source link

ng-model get not the updated value on dp.change event after selecting the picker #13

Open gp4pgit opened 9 years ago

gp4pgit commented 9 years ago

I my case the datetimepicker defined ng-model doesn't get updated values after selecting the picker...

While debugging, I noticed that in line 44 of the angular-bootstrap-datetimepicker-directive.js file ngModelCtrl.$setViewValue(e.target.value); // >>> e.target.value == undefined e.target.value is undefined... thus I changed the code to this: ngModelCtrl.$setViewValue(moment(e.date).format(default_options.format) );

This works for me... :+1: Does anyone have the same problem or what I am doing wrong?

mts88 commented 9 years ago

I have the same problem but your solution doesn't fix it, in my case.

Edit: I fixed using not $scope variable for ng-model. Using local controller variables fixed the problem for me.

gp4pgit commented 8 years ago

I have update the angular-bootstrap-datetimepicker-directive.js file and the problem is still existing. Could someone show me a working example, please. Because my problem is, that the input textbox will be updated, but doesn't call the ng-change vm.startDatePickerDidChangeValue and doesn't update the ng-model... What am I doing wrong? ^^

<div class="input-group date"
    datetimepicker
    datetimepicker-options="{{vm.startDateTimePickerOptions}}"
    ng-change="vm.startDateTimePickerDidChangeValue()"
    ng-model="vm.startDateTimePicker">
    <input submit-required="true" type="text" class="form-control" 
        name="startDateTimePicker" id="startDateTimePicker"/>
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-time"></span>
        </span>
</div>

With the following adjustment in code line 44 of the file angular-bootstrap-datetimepicker-directive.js file, which i mentioned in my first comment, it works fine for me...

ngModelCtrl.$setViewValue(moment(e.date).format(default_options.format) );