amansoni211
amansoni211

Reputation: 929

Access data attribute value in angular 2

I have a form with a id :

<form id="dummyForm">
    <input type="text">
    <input type="submit" value="click me">
</form>

and a div with data attribute, which contains form's id :

<div attr.data-form-id="dummyForm" (click)=hideForm()>Click to hide</div>

how can I get the data-form-id value in hideform() function. so that I can hide the form.

Any Help?

Upvotes: 10

Views: 6768

Answers (1)

G&#252;nter Z&#246;chbauer
G&#252;nter Z&#246;chbauer

Reputation: 657741

<div attr.data-form-id="dummyForm" 
    #me 
    (click)="hideForm(me.getAttribute('data-form-id'))">
  Click to hide
</div>

Upvotes: 16

Related Questions