Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

docs(ngModel.NgModelController): use $evalAsync instead of $apply for events #9891

Closed

Conversation

alexanderchan
Copy link
Contributor

Have the apply called safely during events by using $evalAsync rather than $apply.
This will help ensure that an apply for a user directive is not called during a digest cycle.

…for event handling

Have the apply called safely during events by using `$evalAsync` rather than `$apply`
This will help ensure that an apply for a user directive is not called during a digest cycle.
@alexanderchan
Copy link
Contributor Author

@Narretz and @gkalpak this is the doc update as discussed in #9808. I thought about checking the type of event for some events only but I didn't want to overcomplicate the example.

However, if you think it's better to add a check for the blur (or any other events?) in the example please let me know and I'll update and retest.

@alexanderchan alexanderchan changed the title docs(ngModel.NgModelController) use $evalAsync instead of $apply for events docs(ngModel.NgModelController): use $evalAsync instead of $apply for events Nov 4, 2014
@gkalpak
Copy link
Member

gkalpak commented Nov 11, 2014

LGTM (for what it's worth 😄)

@caitp
Copy link
Contributor

caitp commented Nov 11, 2014

eh, alright

caitp pushed a commit that referenced this pull request Nov 11, 2014
…for event handling

Have the apply called safely during events by using `$evalAsync` rather than `$apply`
This will help ensure that an apply for a user directive is not called during a digest cycle.

Closes #9891
@caitp caitp closed this in 804e750 Nov 11, 2014
@alexanderchan
Copy link
Contributor Author

@caitp, cool. I know it looks a bit trivial but I've seen it happen in the wild. Some issues on a few people's directives that use alternatives such as $timeout which works or even this issue thumbtack/angular-smarty#6, so hopefully some small amount of debugging and issues will be prevented by this 😄

gkalpak referenced this pull request Nov 21, 2014
If the model is blurred during an apply it should trigger
$setTouched asynchronously.

Fixes #8762
Fixes #9808
Closes #10014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants