Reputation: 3014
I am using Angular2 and would like to stick to using vanilla javascript.
Does anybody know how to achieve event binding with vanilla javascript?
Upvotes: 1
Views: 135
Reputation: 3014
Figured it out,
There are actually two ways to do it:
<div (click)="myAction()"></div>
<div on-click="myAction()"></div>
Then in your component:
Class({
constructor: function() {},
myAction: function() {
console.log("hi world");
}
}
Upvotes: 2