[Fixed] How to call a function on checking a checkbox in angular 2.0


I am currently using angular 2.0. In HTML, I have a checkbox, the code is as mentioned below.

<div style="margin-left:15px;">
            <input id="isCheckBox" type="checkbox" checked="checked">

How to call a function only if a checkbox is checked in typescript file?


You can do this,

<input type="checkbox"  id="isCheckBox" (change)="yourfunc($event)"/>

and in typescript,

yourfunc(e) {

Leave a Reply

(*) Required, Your email will not be published