Input onchange with Angular2

Issue

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.

Solution

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

Use instead

(change)="update()"

Answered By – Günter Zöchbauer

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.