Skip to content

Instantly share code, notes, and snippets.

@grantpullen
Last active August 21, 2018 06:54
Show Gist options
  • Select an option

  • Save grantpullen/b4ce1e6734092084f10a5fc9bd1775cc to your computer and use it in GitHub Desktop.

Select an option

Save grantpullen/b4ce1e6734092084f10a5fc9bd1775cc to your computer and use it in GitHub Desktop.
Angular snippets

Angular Snippets

Date pipes in two way ngModel binding within an <input/>

When doing a two way binding [(ngModel)]= to a piped value [(ngModel)]="camp.end_at | date:'yyyy-MM-dd'" you get the following error Parser Error: Cannot have a pipe in an action expression To correct, do one way binding and change the value via (ngModelChange) e.g.


<input type="date" name="eday" min="2018-08-01" class="form-control rounded" [(ngModel)]="camp.end_at | date:'yyyy-MM-dd'"  (ngModelChange)="camp.end_at=$event">

source https://stackoverflow.com/questions/39642882/using-pipes-within-ngmodel-on-input-elements-in-angular

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment