angular Property 'value' does not exist on type 'HTMLElement'.
document.getElementById() returns the type HTMLElement which does not contain a value property.
The subtype HTMLInputElement does however contain the value property.
So a solution is to cast the result of getElementById() to HTMLInputElement like this:
var inputValue = (<HTMLInputElement>document.getElementById(elementId)).value;
<> is the casting operator in typescript.
See TypeScript: casting HTMLElement: https://fireflysemantics.medium.com/casting-htmlelement-to-htmltextareaelement-in-typescript-f047cde4b4c3
The resulting javascript from the line above looks like this:
inputValue = (document.getElementById(elementId)).value;
i.e. containing no type information.var inputValue = (<HTMLInputElement>document.getElementById(elementId)).value;
Also in JavaScript:
- immutable values
- get url params angular
- html select multiple selected values
- how to pass state from parent to child in react
- es module __dirname alternative
- what are the two ways to create an array in javascript examples?
- disable autocomplete in react fields
- if json valide js
- how to add seconds to time in js
- how to create my own filter in js
- pyspark dataframe json string
- vue js default props
- click on button submitting the form in angular
- How to scan a folder for documents with javascript
- convert app function to class component react native
- buttons js before submit
- knex js join schema
- compare two arrays javascript
- javacript is checkbox checked
- python serialization json marshmallow
- json decode android
- javascript round to 2 decimal places
- how to get client.user.avatar
- put new attribute on html tag using javascript