1

I have a date input that is bound to a model. If the input is inside a directive, then the date input doesn't have it's initial value set. Updating the input does update the model, it's just the initial value that isn't set. It works fine in Chrome, but not in Firefox.

Here is the relevant codepen

HTML:

<div ng-app="app" ng-controller="main">
 <input type=text ng-model="mainDateModel">
 <input type=date ng-model="mainDateModel">
 Main date model: {{mainDateModel}}
 <dir></dir>
</div>

JS:

angular.module('app', [])
angular.module('app').controller('main', function($scope) {
 $scope.mainDateModel = new Date();
})
angular.module('app').directive('dir', function() {
 return {
  template: '<input type=text ng-model="dirDateModel">' +
    '<input type=date ng-model="dirDateModel">' + 
    ' Dir date model: {{dirDateModel}}',
  controller: function($scope) {
    $scope.dirDateModel = new Date();
  }
 }
})

It should show 12/13/2018 where it says mm/dd/yyyy Codepen screenshot

Is there something I am doing wrong or is there an easy way to work around it? The text input is correctly initialized, just the date isn't.

Update: Here is the bug I filed in Bugzilla

3
  • 1
    That codepen works for me in firefox. It's quite strange that for you isn't working. No errors in the console or something? Commented Dec 13, 2018 at 19:10
  • I'm using Firefox 65.0b4 (64-bit). I've added a screenshot to show where it isn't working. Commented Dec 13, 2018 at 19:18
  • 1
    My firefox version is 64.0, don't know if that's the problem. Maybe you could try downgrading your firefox version just for trying. Commented Dec 13, 2018 at 19:37

1 Answer 1

1

Seems like an issue with your browser version. For me it works both in chrome and firefox.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.