How do I use a select element's onchange event to pass an object instead of a string in AngularDart?

Issue

Here’s what I’m trying to accomplish.

<select (ngModelChange)="addChild($event)">
    <option>Add</option>
    <option [value]="null">New Item</option>
    <option *ngFor="let child of menuItem.children" [value]="child">
        {{child.title}}
    </option>
</select>

While it compiles, the addChild method is not called. VSCode is reporting that “The bound output ngModelChange does not exist on any directive or on the element” – so what directive do I need to add?

Solution

AngularDart’s SelectElement only supports Strings for values. If you want to pass arbitrary objects, you will need to use a different component – one that supports such functionality.

Answered By – Krolaw

Answer Checked By – Robin (FlutterFixes Admin)

Leave a Reply

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