One way to do this is through a setter. Let's say you have a checkbox:
<input type="checkbox">
Create your own field in your view model, and then wrap it in the receiver and installer:
get isChecked(){ return this._isChecked; } set isChecked(value){ this._isChecked = value;
Then bind isChecked to the view:
<input type="checkbox" checked.bind="isChecked">
Each time the checkbox is checked or unchecked, the caller will be called, and you can call any method you want using setter.
Another unconventional way to achieve this is to use the @bindable decorator as follows:
@bindable isChecked: boolean;
This is unconventional because you probably don't want isChecked be a binder, but the decorator gives you access to the isCheckedChanged method:
isCheckedChanged(newValue, oldValue){
And, of course, there is a change event that you can catch with change.trigger and change.delegate , but this was already mentioned in another answer
source share