Skip to content
Advertisement

How to access a previous value from a two way binded form input control?

Given the form here, I would like to be able to Update data in a SQL Table. In order to create the SQL query needed to make this happen I’ll have to pass in both the previous row’s value and the new row’s value to make the proper comparison.

Example SQL Update Statement:

Since my input is using two way binding however, I always get the new value when trying to pass it to my SQL service. Is there a way to access the row’s previous value prior to sending it for update?

Form HTML:

Component TS file:

SQL Service TS:

Advertisement

Answer

hi create one more object(e.g prevValue) store value in it.that should be deepcopy not shallow copy.. use JSON.stringify and JSON.parse to copy value in object. e.g In newValue object you store the new value, before assigning the new value, save newValue in prevValue, by this you will have prevValue, like if you want first value than don’t update preValue

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement