ahmed_sa Ответов: 0

Ошибка при создании элемента управления date to datepicker в формат dd/mm/yyyy ?


Проблема
при преобразовании элемента управления date picker в формат dd/mm/yyyy я получаю ошибку, как показано ниже
compiler.js:2427 Uncaught Error: Template parse errors:
Parser Error: Cannot have a pipe in an action expression at column 25 in [api.SHeader.salesDate | date:'dd/MM/yyyy'=$event] in ng:///AppModule/OrderComponent.html@23:103 ("           <input name="salesDate" matInput [matDatepicker]="salesDate" placeholder="Select a date" [ERROR ->][(ngModel)] = "api.SHeader.salesDate | date:'dd/MM/yyyy'" (ngModelChange)="api.SHeader.salesDate= $ev"): ng:///AppModule/OrderComponent.html@23:103
Parser Error: Unexpected token , expected identifier or keyword at the end of the expression [api.SHeader.salesDate | date:'dd/MM/yyyy'=$event] in ng:///AppModule/OrderComponent.html@23:103 ("           <input name="salesDate" matInput [matDatepicker]="salesDate" placeholder="Select a date" [ERROR ->][(ngModel)] = "api.SHeader.salesDate | date:'dd/MM/yyyy'" (ngModelChange)="api.SHeader.salesDate= $ev"): ng:///AppModule/OrderComponent.html@23:103
The pipe '' could not be found ("           <input name="salesDate" matInput [matDatepicker]="salesDate" placeholder="Select a date" [ERROR ->][(ngModel)] = "api.SHeader.salesDate | date:'dd/MM/yyyy'" (ngModelChange)="api.SHeader.salesDate= $ev"): ng:///AppModule/OrderComponent.html@23:103
Parser Error: Cannot have a pipe in an action expression at column 25 in [api.SHeader.salesDate | date:'dd/MM/yyyy'=$event] in ng:///AppModule/OrderComponent.html@23:103 ("]="salesDate" placeholder="Select a date" [(ngModel)] = "api.SHeader.salesDate | date:'dd/MM/yyyy'" [ERROR ->](ngModelChange)="api.SHeader.salesDate= $event"  >


Что я уже пробовал:

<mat-form-field>
               <mat-label>Date</mat-label>
             <input name="salesDate" matInput [matDatepicker]="salesDate" placeholder="Select a date" [(ngModel)] = "api.SHeader.salesDate | date:'dd/MM/yyyy'" (ngModelChange)="api.SHeader.salesDate= $event"  >
             <mat-datepicker-toggle matSuffix [for]="salesDate"></mat-datepicker-toggle>
             <mat-datepicker #salesDate></mat-datepicker>
         </mat-form-field>

Gerry Schmitz

Он говорит, что ему не нравится ваша "труба"; это труба: |

Это не похоже на "действие" с вашей трубкой; это действие: =

0 Ответов