Leonid Lunin Leonid Lunin - 4 months ago 45
Dart Question

Input onchange with Angular2

I try to detect on change with dart. Example html:

<div>
<input id="photoUpload" type="file" name="photo" (onchange)="update()" multiple>
</div>


Dart:

@Component(
selector: "photo-upload-dialog", templateUrl: "photo_upload_dialog.html")
class PhotoUploadDialog {


update() async {
print('Changed!');
}
}


But nothing in a console.

Answer

onChange is the default event handler name, not the event name.

Use instead

(change)="update()"