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

docs(ngModel): getterSetter and arguments.length vs. angular.isDefined #11604

Closed
wants to merge 1 commit into from

Conversation

yankee42
Copy link
Contributor

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:

ctrl.$modelValue = allValid ? modelValue : undefined;

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).

…ewName)` to distinguish getter/setter usage
@googlebot
Copy link

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 it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@yankee42
Copy link
Contributor Author

I signed and also added my github username. I suppose I do not need to set the username AND the email address?!

@googlebot
Copy link

CLAs look good, thanks!

@Narretz Narretz self-assigned this Apr 20, 2015
@Narretz Narretz modified the milestone: Backlog Apr 20, 2015
@Narretz Narretz closed this in d20de4a Apr 27, 2015
Narretz pushed a commit that referenced this pull request Apr 27, 2015
…ewName)` to distinguish getter/setter usage

Closes #11604
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
@icorne
Copy link

icorne commented Nov 22, 2016

I just ran into this issue, Should this not be on master as well?

@gkalpak
Copy link
Member

gkalpak commented Nov 22, 2016

Not sure what you mean. This is a docs change and it has been merged into master as well.

@icorne
Copy link

icorne commented Nov 23, 2016

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!

@gkalpak
Copy link
Member

gkalpak commented Nov 23, 2016

Np 😃 You were probably viewing the docs of an older version the other day (there is version picker in the top-left).

@yankee42 yankee42 deleted the patch-2 branch May 13, 2017 14:29
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.

5 participants