Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 891
amansoni211 Avatar asked Feb 13 '17 07:02

amansoni211


1 Answers

<div attr.data-form-id="dummyForm" 
    #me 
    (click)="hideForm(me.getAttribute('data-form-id'))">
  Click to hide
</div>
like image 115
Günter Zöchbauer Avatar answered Oct 02 '22 14:10

Günter Zöchbauer