#How to show a string in a input and keep an object in the FormControl of the input.

3 messages · Page 1 of 1 (latest)

tropic berry
#

Let's say I have an object { id: 1, code: 'TS', description: 'Typescript' }. And I want to show a string "TS | Typescript" in the input and inside the formControl I want to keep the object and not a string. In this piece of image code, theoretically it does this, there are times when it keeps the object in the formControl and shows a string, but there are times when it shows [object Object] in the input.

odd temple
#

You should be able to use a Control Value Accessor for that.