在土星日期选择器中将日期格式转换为“中”

时间:2019-03-06 07:18:25

标签: angular angular-material

我正在尝试使用ngModel将日期格式更改为“ medium”,但未将其转换为所需格式

下面是代码:-

<form  #form="ngForm" (ngSubmit)="addDateStatus(form,index)">

<mat-form-field>

  <input matInput placeholder="Choose a date" [ngModel]="form.date | date:'mediumDate'" name="date">
  <input autocomplete="off" matInput placeholder="Choose a date" [max]="maxDate" [satDatepicker]="picker" name="date" (dateChange)="dateRangeSelection($event,form.date)" [hidden]='true' [(ngModel)]="form.date">
  <sat-datepicker #picker [rangeMode]="true" [closeAfterSelection]="false">
  </sat-datepicker>
  <sat-datepicker-toggle matSuffix [for]="picker"></sat-datepicker-toggle>
</mat-form-field>
</form>

这是我使用管道连接到ngModel时遇到的错误

AllUsersComponent.html:13 ERROR Error: InvalidPipeArgument: 'Unable to convert "[object Object]" into a date' for pipe 'DatePipe' at invalidPipeArgumentError (common.js:4139) at DatePipe.push../node_modules/@angular/common/fesm5/common.js.DatePipe.transform
(common.js:5066) at checkAndUpdatePureExpressionInline (core.js:22797) at checkAndUpdateNodeInline (core.js:23366) at checkAndUpdateNode (core.js:23324) at debugCheckAndUpdateNode (core.js:23958) at debugCheckDirectivesFn (core.js:23918) at Object.eval
[as updateDirectives] (AllUsersComponent.html:13) at Object.debugUpdateDirectives [as updateDirectives] (core.js:23910) at checkAndUpdateView (core.js:23306) View_AllUsersComponent_1 @ AllUsersComponent.html:13 push../node_modules/@angular/core/fesm5/core.js.DebugContext_.logError
@ core.js:24138 push../node_modules/@angular/core/fesm5/core.js.ErrorHandler.handleError @ core.js:15771 (anonymous) @ core.js:18125 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:391 push../node_modules/zone.js/dist/zone.js.Zone.run
@ zone.js:150 push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular @ core.js:17257 push../node_modules/@angular/core/fesm5/core.js.ApplicationRef.tick @ core.js:18125 (anonymous) @ core.js:18009 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke
@ zone.js:391 onInvoke @ core.js:17298 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke @ zone.js:390 push../node_modules/zone.js/dist/zone.js.Zone.run @ zone.js:150 push../node_modules/@angular/core/fesm5/core.js.NgZone.run @ core.js:17212
next @ core.js:18009 schedulerFn @ core.js:13514 push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub @ Subscriber.js:194 push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.next @ Subscriber.js:132 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._next
@ Subscriber.js:76 push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next @ Subscriber.js:53 push../node_modules/rxjs/_esm5/internal/Subject.js.Subject.next @ Subject.js:47 push../node_modules/@angular/core/fesm5/core.js.EventEmitter.emit
@ core.js:13498 checkStable @ core.js:17267 onLeave @ core.js:17334 onInvokeTask @ core.js:17292 push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask @ zone.js:422 push../node_modules/zone.js/dist/zone.js.Zone.runTask @ zone.js:195 push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask
@ zone.js:498 invokeTask @ zone.js:1744 globalZoneAwareCallback @ zone.js:1770 AllUsersComponent.html:13 ERROR CONTEXT DebugContext_ {view: {…}, nodeIndex: 13, nodeDef: {…}, elDef: {…}, elView: {…}}

0 个答案:

没有答案