user2202911
user2202911

Reputation: 3014

Event binding in Angular2 with vanilla javascript

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

Answers (1)

user2202911
user2202911

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

Related Questions