Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular Form Properties not affected when selecting a date #20

Open
danielforsberg opened this issue Apr 26, 2016 · 4 comments
Open

Angular Form Properties not affected when selecting a date #20

danielforsberg opened this issue Apr 26, 2016 · 4 comments

Comments

@danielforsberg
Copy link

danielforsberg commented Apr 26, 2016

As topic states the form properties is not affected when I choose a date (Google Chrome Version 50.0.2661.86 (64-bit))

Here's what I am trying to do:

        <form name="form">
                <input ng-model="model"
                       name="dateTime"
                       datetime-picker
                       date-format="yyyy-MM-dd HH:mm:ss"
                       close-on-select="true" />
            <span ng-show="form.dateTime.$dirty" class="notice">{{ message }}</span>
        </form>

The message only shows if I manually make some input to the field, not when choosing a date from the datetime-picker

@thethakuri
Copy link

Try :
<span ng-show="!form.dateTime.$pristine" class="notice">{{ message }}</span>

@danielforsberg
Copy link
Author

Thanks for the input but I get the same result.

@ryan-morris
Copy link

We are seeing the same issue. I made a small change that seems to work but I do not know if this is the best fix. Any thoughts?

var datetimePicker  = function($parse, DatetimePicker) {
    return {
      // An ngModel is required to get the controller argument
      require: 'ngModel',
      link: function(scope, element, attrs, ctrl) {
        // Attach validation watcher
        scope.$watch(attrs.ngModel, function(value, old) {
          //force dirty on update
          if (value !== old) {
            ctrl.$setDirty();
          }

@danielforsberg
Copy link
Author

Thank you @ryan-morris for your input, it works. I'm not sure if it's the right way to do it either but I will use it until further notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants