0

I'm stuck in a strange situation where my data is getting lost while setting it to a object. Will try to elaborate the situation. this.tempRenewals = this.findById(this.renewals,'id',21869);

findById(arr,searchBy,val){
    if(!val){
       return {};
    }
    if(arr){
       return arr.find(x => x[searchBy] == val);                    
    }
}

value of renewals object

[{"id":21869,"benefitEndDate":"02/22/2019","premium":0,"enrollmentStatus":"INFORCE","policyId":"test21331","productType":null,"stEnrollmentId":null}]

After findById is evaluated, I get date values undefined. I get below value in tempRenewals.

"{"id":21869,"premium":0,"enrollmentStatus":"INFORCE","policyId":"test21331","productType":null,"stEnrollmentId":null}"

After debugging got to know, its losing value after the below code is evaluated.

 this._setProperty(property, value);    

in property-accessors.html(polymer\lib\mixins\property-accessors.html), its getting called internally.

I'm using 2-way binding with vaadin-date-picker, which is actually causing issue.

<vaadin-date-picker value="{{tempRenewals.benefitStartDate}}"></vaadin-date-picker>

But I'm unable to identify how do I resolve it.

ssindelar
  • 2,833
  • 1
  • 17
  • 36

2 Answers2

1

The way you use this._setProperty(property, value); is only if property property is defined as readOnly. So, If you want to set a property with a value. try to use this.set(property, value);.

Cappittall
  • 3,300
  • 3
  • 15
  • 23
1

The issue was caused due to incorrect format of date "benefitEndDate":"02/22/2019". Vaadin-date-picker was not able to identify the date in this format causing it to set empty value, thus clearing out the value as it is two-way binding.