1

I am using Angular2 and would like to stick to using vanilla javascript.

Does anybody know how to achieve event binding with vanilla javascript?

2
  • 1
    That is what angular does not want you to do. Commented Jun 4, 2016 at 10:54
  • @Jigar I dont care Commented Jun 4, 2016 at 11:28

1 Answer 1

2

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");
        }
      }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.