New to Angular and Typescript, trying to set a control's attribute using a method on my Component. Is it possible to send the Button control itself as an argument?
<input type="button" id="Button1" data-something="{{ GetSomething(this) }}">
And my method on my Component:
GetSomething(sender) {
//do something with sender being the Button
console.log(sender.id);
return "garbage";
}
asked Apr 17, 2018 at 17:11
mxmissile
11.7k7 gold badges57 silver badges85 bronze badges
1 Answer 1
If by this, you meant the HTMLElement then the following might work:
<input type="button" id="Buttong1" #someBtn class="{{ GetButtonClass(someBtn)}}">
Or read up on ngClass or Class binding:
answered Apr 17, 2018 at 17:17
Chau Tran
5,1481 gold badge26 silver badges40 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-js
*ngClassor[class.foo]and the button element wouldn't really tell you anything.data-attribute instead. I used class just for this example. Will edit.