You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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?
The text was updated successfully, but these errors were encountered:
When a
md-radio-group
is bound via[(ngModel)]
to a class property, the value emitted by thechange
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 inngOnInit
. If the user selects the radio button with value FALSE, in theonChange
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?
The text was updated successfully, but these errors were encountered: