1

I'm trying to replace the textbox with the PrimeNG calendar but keep the functionality of it storing the value that will be saved in the database.

I thought that maybe something like combining input and p-calendar would work:

<p-calendar #CreateDate [(ngModel)]="CreateDates" [value]="{{CreateDates}}" [showIcon]="true" dateFormat="dd.mm.yy"></p-calendar>

but this obviously doesn't work and results in a lot of errors.

The exception I am getting:

Parser Error: Got interpolation ({{}}) where expression was expected

Along with the following errors: enter image description here

Antikhippe
  • 6,316
  • 2
  • 28
  • 43
ire
  • 491
  • 2
  • 12
  • 26
  • what is your issue when you use just ? – Eddie Martinez Apr 10 '17 at 13:34
  • These are the errors I get when using the the way I mentioned in the botton code snipet of my post: http://imgur.com/a/Y3Zci – ire Apr 10 '17 at 13:38
  • Also the snippet really doesnt help and just draws attention away from your real issue which is when using p-calendar you get an error. To make your question friendlier to answer I would remove all that part bout the input and snippet and copy and paste the exception from the image so if someone is having the same exception it will help them. – Eddie Martinez Apr 10 '17 at 13:45
  • 1
    Thanks for the lesson and edit. I added the error image because why not. – ire Apr 10 '17 at 13:51

1 Answers1

2

When using an Angular2 directive you do not have to use the interpolation syntax to access a value. Also because you are two-way binding to the variable CreateDates it will automatically add the value to your calendar as long as its a valid date. Make sure the value in CreateDates is a valid date and do this

<p-calendar #CreateDate [(ngModel)]="CreateDates" 
[showIcon]="true" dateFormat="dd.mm.yy"></p-calendar>
Eddie Martinez
  • 13,582
  • 13
  • 81
  • 106