indrimuska / angular-moment-picker

Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
http://indrimuska.github.io/angular-moment-picker/
MIT License
525 stars 226 forks source link

moment-picker doesn't take dynamic value to be displayed as initial value #241

Open SaloniDesai opened 6 years ago

SaloniDesai commented 6 years ago

I am using angular-moment-picker library on the scatterplot chart created using d3.js v3. I want to set the initial value on the picker to be based on where user clicks on the chart. But it seems, moment-picker only sets initial value that is defined at the beginning of the controller.

<input class="form-control" ng-init="vm.input" ng-model="vm.input" ng-model-options="{ updateOn: 'blur' }" placeholder="Click here to select a date"
       moment-picker="vm.input" style="width:25em;height:25px;" format="LL LTS">

//controller where vm.input value is obtained
newData = d3.mouse(this);
vm.input = moment(xScale.invert(newData[0])).format("ddd MMM D YYYY HH:mm:ss z");

With the code above, I still get placeholder on the moment-picker input box instead of the time saved in vm.input variable. Is there a way to make moment-picker to display value in vm.input obtained in as initial value ? I even tried using ng-init directive but that doesn't work either.