This situation is really getting on my nerves.
I have a hidden input box that looks like this:
<input type='hidden' id='iFrameDrivenImageValue' value='n/a'>
Now, I am attempting to read its value from .ts file in order to submit it to the database. However, I am facing an issue during compilation of the TypeScript code. It is stopping with an error message that says:
ERROR in /Users/...component.ts (4773,89): Property 'value' does not exist on type 'HTMLElement'.
I tried,
<HTMLInputElement>document.getElementById("iFrameDrivenImageValue").value
;
also tried,
<HTMLInputElement>document.getElementById("iFrameDrivenImageValue")?.value
;
and even tried,
theForm.form.controls['iFrameDrivenImageValue'].value
;
When I debug using Chrome's debugger, it successfully displays the value of
document.getElementById("iFrameDrivenImageValue").value
as 'n/a'.
How can I make TypeScript see the same thing? Or at least resolve it so I can compile the code without issues?
One might wonder why I am not simply binding the value two-way. Well, the reason I am exploring this unconventional approach is because Angular fails to detect changes made within an ngForm input field by an iFrame script. Quite perplexing!
From Angular's perspective, the value altered by the iframe within the ngForm remains unchanged and the theForm.form.controls are oblivious to its recent modification.
Since all my attempts have fallen short, I reluctantly resorted to a more traditional method, but TypeScript refuses to compile.