Click here to Skip to main content
15,884,922 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Problem
when convert date picker control to formate dd/mm/yyyy i get error as below
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"  >


What I have tried:

<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>
Posted
Comments
[no name] 9-Mar-19 0:25am    
It's telling it doesn't like your "pipe"; this is a pipe: |

It doesn't like an "action" with your pipe; this is an action: =

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900