Format date value in material design to remove time -


i have following input on form:

<md-input-container class="md-block" flex>     <label>install date</label>     <input type="text" date="yyyy-mm-dd" ng-model="selectedcompanydetail.installdate" disabled> </md-input-container> 

as can tell, want date displayed format yyyy-mm-dd. however, getting this: 1993-01-01t00:00:00.

it looks correct if this:

<md-input-container class="md-block" flex>     <label>install date</label>     <input type="text" ng-model="selectedcompanydetail.installdate | date:'yyyy-mm-dd':'utc'" disabled> </md-input-container> 

but, error in developer tools:

angular.js:13307 error: [ngmodel:nonassign] http://errors.angularjs.org/1.5.0-rc.2/ngmodel/nonassign?p0=selectedcompanydetail.installdate%20%7cnanate%3a'yyyy-mm-dd'%3a'utc'&p1=%3cinput%20type%3d%22text%22%20date%3d%22yyyy-mm-dd%22%20ng-model%3d%selectedcompanydetail.installdate%20%7c%date%3a'yyyy-mm-dd'%3a'utc'%22%20disabled%3d%22%22%class%3d%22ng-pristine%20ng-untouched%20ng-valid%22%3e @ error (native) @ https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0-rc.2/angular.min.js:6:421

i can still use view, every date field has same error.

i have many date fields , don't want add filter each 1 suggested here: angularjs formatted date in ng-model

there has native way format date input date without time.

suggestions or ideas?

you can use package handle kind of date , time manipulation. https://github.com/urish/angular-moment

i use this.

selectedcompanydetail.installdatenewformat = moment(selectedcompanydetail.installdate).format('yyyy-mm-dd'); 

you must model store new date since md-datepicker allows data javascript object. while format returns plain text(string).


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -