html element add data to the data attribute angular code example

Example: get all html element data using angular

File your-component-name.component.html

<input type="text" #inputbox>
<button type="submit" (click)="getelementData()">Show element data</button>

file your-component-name.component.ts
In the class make function named as 

getelementData(nameinput){
 console.log(nameinput);  // output will be the whole button element with their attributes
 // if you want to show specific attribute data then 
 console.log(nameinput.value);  // it will reflects the value of textbox which has been entered
}

Tags:

Html Example