Angular 2/Dart: Binding multiple events at once

Issue

In a Angular 2 / Dart Template I have the following line of code:

<input (keyup)="addressChanged('destination')"
       (change)="addressChanged('destination')"
       type="text"
       value="" />

Is there a syntactical way to bind multiple events at once?

Like this:

<input (keyup,change)="addressChanged('destination')"
       type="text" value="" />

Otherwise with many events there is a lot of redundancy …

Solution

I do not think this is currently supported. You can file a feature request:
https://github.com/dart-lang/angular2/issues

Usually though each event has a separate handler – why you need to do the same thing on both keyup and change?

If this is a pattern you run into with lot of inputs you could write a directive that would handle both events.

Answered By – rkj

Answer Checked By – Katrina (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *