My configuration
I am retrieving a value
from the database as a number
. This value must always be a number, except when displaying it in an input
element and validating user input. In those cases, the number needs to be a HEX value.
Here is the desired process:
value: 200
is fetched from the service.?value=200
is used as a parameter in the router.value: 'c8'
is shown in theinput[type=text]
on the interface.- The user edits this value to
fa
- The validator should validate
fa
to ensure it's a valid HEX expression. - If valid,
value = hex2Number('fa')
will result invalue: 250
in the model, while still displayingfa
in theinput
for editing. value: 250
will then be utilized in the router and sent back to the server.
This same scenario applies to other data types like minutes:seconds being edited and seconds stored in the DB.
I do not need assistance with the hex2Number()
method ;-)
My queries
- Can this be achieved using Reactive Forms?
- ... or would I need to switch to Template Driven Forms?
- Is there a recommended approach for managing different data between the GUI and underlying model?
Thank you in advance!