set data-attribute in angular code example

Example: get all html element data using angular

File your-component-name.component.html




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:

Misc Example