Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

angular cannot access event.target.value of input element using $event

/*
event.target here is an HTMLElement which is the parent of all HTML elements, 
but isn't guaranteed to have the property value. 
TypeScript detects this and throws the error. 
Cast event.target to the appropriate HTML element to ensure it is 
HTMLInputElement which does have a value property:
*/

(<HTMLInputElement>event.target).value

// Here's another fix that works for me:
(event.target as HTMLInputElement).value
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #angular #access #input #element
ADD COMMENT
Topic
Name
1+7 =