Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RoxKilly opened this issue May 16, 2016 · 1 comment · Fixed by #456
Closed

Comments

@RoxKilly
Copy link

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?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants