JavaScript AngularJS : Pass results from datepicker to ng-model

I have a datetimepicker, I'm needing this to pass the date inside the text to the model.

I would place this in a fiddle but i don't know how as it has the bootstrap timepicker located here http://eonasdan.github.io/bootstrap-datetimepicker angular(obvs) and other stuff

This is what i have so far;

  <div class="form-group">
                  <div class='input-group date' ng-model="package.timeA">
                      <input type='text' id='datetimepicker3' ng-model="package.timeA" ng-change="alert('Hello')" class="form-control" />
                      <span class="input-group-addon" ng-model="package.timeA">
                          <span class="glyphicon glyphicon-time"></span>
                      </span>
                  </div>
              </div>

          <script type="text/javascript">
              $(function () {
                  $('#datetimepicker3').datetimepicker({
                      format: 'LT'
                  }).on("dp.change", function(e) {
                    document.getElementById('datetimepicker3').value = e.date;
                  });
              });
          </script>

The datetimepicker needs to pass into the model, Totally stuck until it does so i can submit it to the DB

Any Ideas?>

Answer:1

You will need to trigger the "input" event of #datetimepicker3 since ng-model listens for this event hence it shall update its value :

<script type="text/javascript">
              $(function () {
                  $('#datetimepicker3').datetimepicker({
                      format: 'LT'
                  }).on("dp.change", function(e) {
                    document.getElementById('datetimepicker3').value = e.date;
                    $('#datetimepicker3').trigger('input'); // trigger input event
                  });
              });
          </script>

As per How does AngularJS internally catch events like 'onclick', 'onchange'?

Angular, by default, listens for input event, and, in case it's not supported by the browser, it will fall back to keydown + change events.

Events are binded with jQlite's bind method (unless you also have a full jQuery included, in which case its bind method will take over).

Answer:2

Let's say I have a div like below and my goal is to set it's css class to some computed string of classes based on the name of a vue data model property passed to the getClassText method: <div :...

Let's say I have a div like below and my goal is to set it's css class to some computed string of classes based on the name of a vue data model property passed to the getClassText method: <div :...

  1. data value model
  2. key value data model
  3. key value data model example
  4. nursing value data model
  5. entity value data model
  6. attribute value data model
  7. cube value data model
  8. value proposition data model
  9. multi-value data model
  10. data value chain model
  11. entity attribute value data model
  12. data value creation model
  13. nosql key value data model
  14. value of enterprise data model
  15. data value business model
  16. value of conceptual data model
  17. customer value model data
  18. key value pair data model
  19. key value store data model
  20. data value chain reference model

I'm using Mapbox GL JS API to manipulate a Mapbox map. Right before I upload my result (which is a canvas.toDataURL) to the server through HTTP I need to resize my map (bigger resolution) and then use ...

I'm using Mapbox GL JS API to manipulate a Mapbox map. Right before I upload my result (which is a canvas.toDataURL) to the server through HTTP I need to resize my map (bigger resolution) and then use ...

  1. mapbox event on click
  2. mapbox on event

I'm trying to make something easy but, it doesn't work. I have this html <div class="positionDiv"> <img class="eyes" ng-model="showPasswordIsChecked" ng-click="afficherMdp()" ng-...

I'm trying to make something easy but, it doesn't work. I have this html <div class="positionDiv"> <img class="eyes" ng-model="showPasswordIsChecked" ng-click="afficherMdp()" ng-...

  1. ngmodelchange
  2. ngmodel angular
  3. ngmodeloptions
  4. ngmodeloptions u003d standalone true
  5. ngmodel checkbox
  6. ngmodel not working
  7. ngmodelgroup
  8. ngmodel radio button
  9. ngmodel select
  10. ngmodel on change
  11. ngmodel deprecated
  12. ngmodel vs formcontrol
  13. ngmodelchange debounce
  14. ngmodelchange not firing
  15. ngmodel change event
  16. ngmodel angularjs
  17. ngmodel two way binding
  18. ngmodel vs value
  19. ngmodel one way binding
  20. ngmodel pipe

I am very new to React, currently doing a small project of using GitHub API to return a search result via AJAX and be able to list that result on the screen. Currently I am using a for loop to iterate ...

I am very new to React, currently doing a small project of using GitHub API to return a search result via AJAX and be able to list that result on the screen. Currently I am using a for loop to iterate ...

  1. react setstate only if changed
  2. react setstate only one property
  3. react setstate only one property of object
  4. react setstate only part of state
  5. react setstate only if mounted
  6. react setstate change only one property
  7. react setstate update only one property
  8. react setstate only once