-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs(ngModel): getterSetter and arguments.length
vs. angular.isDefined
#11604
Conversation
…ewName)` to distinguish getter/setter usage
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed and also added my github username. I suppose I do not need to set the username AND the email address?! |
CLAs look good, thanks! |
…ewName)` to distinguish getter/setter usage Closes #11604
…ewName)` to distinguish getter/setter usage Closes angular#11604
I just ran into this issue, Should this not be on master as well? |
Not sure what you mean. This is a docs change and it has been merged into master as well. |
I'm not sure either, yesterday I still saw it with the angular.isDefined , today, it's changed to this version. Maybe my mind is playing tricks on me. Sorry for the disturbance! |
Np 😃 You were probably viewing the docs of an older version the other day (there is version picker in the top-left). |
When using
ng-model-options="{ getterSetter: true }"
one should be aware that the getter/setter method could be called with an argument set to undefined even if the method is used as setter. This e.g. happens when the model is invalid:angular.js/src/ng/directive/ngModel.js
Line 535 in dd8b157
Using
arguments.length
reliably detects whether the getter/setter should act as getter or setter.Credits for the concept:
#11361 (comment)
I believe that this should be documented as failing to realise this can cause weird behaviour and large time spendings on hunting bugs (at least that happened to me).