0

I have an ngFor directive bound to a list of objects with an option element. I bound the id property of the object to ngValue to be used later. The odd thing I've noticed is that when I get the value in the .ts file, part of the id is missing from the value I got from the database. When I use the value attribute instead, I get the whole id.

You can see the last 6 characters missing in the ng-reflect

The picture shows the difference between the two attributes in the last 6 characters.

Anyone know why this is happening? Is there something about ng-reflect that limits the length of a string?

Brad K
  • 177
  • 1
  • 10

2 Answers2

2

I suppose the answer may be here: What does the "ng-reflect-*" attribute do in Angular2/4?

As for me the better way to store such kind of properties is using data-attribute:

<option [attr.data-id]="id"></option>
Dmitry Sobolevsky
  • 1,171
  • 6
  • 12
0

"Limit the size of the value as otherwise the DOM just gets polluted." https://github.com/angular/angular/blob/master/packages/core/src/util/ng_reflect.ts

Generally ngValue is used for objects.

nll_ptr
  • 864
  • 8
  • 11