Skip to content

Should md-radio-group (change) event update the model before calling the event handler? #448

Closed
@RoxKilly

Description

@RoxKilly

When a md-radio-group is bound via [(ngModel)] to a class property, the value emitted by the change event and passed to the event handler does not match the class property.

Example:
<md-radio-group name="mastery-group" [(ngModel)]="_chosen" (change)="onChange($event.value)">

Suppose that _chosen is set to TRUE in ngOnInit. If the user selects the radio button with value FALSE, in the onChange handler, the value received will be FALSE (as expected), but _chosen will still equal TRUE (unexpected). _chosen is not set to FALSE until after the event handler is run. It seems the event is triggered before the ngModel bound property is updated. Is this by design?

It seems inconsistent with how Angular2 manages other events. Typically, if an input is [(ngModel)] bound to a class property, you don't need to pass the event to the handler to figure out the new value. The handler is able to read the new value directly from the class property.

I'm a newbie at Angular so I'm not too sure about this. Am I wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions