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

Fixes code example in docs #7730

Closed
wants to merge 2 commits into from
Closed

Conversation

winescout
Copy link

@mary-poppins
Copy link

Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.

  • Uses the issue template (#7730)

If you need to make changes to your pull request, you can update the commit with git commit --amend.
Then, update the pull request with git push -f.

Thanks again for your help!

@mary-poppins
Copy link

I'm sorry, but I wasn't able to verify your Contributor License Agreement (CLA) signature. CLA signature is required for any code contributions to AngularJS.

Please sign our CLA and ensure that the CLA signature email address and the email address in this PR's commits match.

If you signed the CLA as a corporation, please let us know the company's name.

Thanks a bunch!

PS: If you signed the CLA in the past then most likely the email addresses don't match. Please sign the CLA again or update the email address in the commit of this PR.
PS2: If you are a Googler, please sign the CLA as well to simplify the CLA verification process.

@rodyhaddad
Copy link
Contributor

I believe the code works as is, since User.get returns an empty object that will be later populated.
And the successFn parameter only gets called after the server returns a response.

It can be a bit confusing though, so I'll leave the PR open for someone to chip in.

@mary-poppins
Copy link

CLA signature verified! Thank you!

Someone from the team will now triage your PR and it will be processed based on the determined priority (doc updates and fixes with tests are prioritized over other changes).

@winescout winescout added cla: yes and removed cla: no labels Jun 7, 2014
Added sentence detailing why the success callback has access to the resource assigned in the request.
@winescout
Copy link
Author

Interesting Rody. Thanks for chiming in. It wasn't clear to me how that was working, and looking at the example around 281 shows the same code, but passing the user into the callback.

I reverted the original change, and added a sentence describing the behavior you lay out.

@@ -191,7 +191,9 @@ function shallowClearAndCopy(src, dst) {
* usually the resource is assigned to a model which is then rendered by the view. Having an empty
* object results in no rendering, once the data arrives from the server then the object is
* populated with the data and the view automatically re-renders itself showing the new data. This
* means that in most cases one never has to write a callback function for the action methods.
* means that in most cases one never has to write a callback function for the action methods.
* Callbacks are evaluated in the same context as the initiating action method, providing access
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the word "context" makes it seems as if the this of the function will be the resource object, which is not the case.

Maybe this line can have the following added to it: [...] arguments, where the value is the resulting resource instance or collection object?

@Narretz Narretz self-assigned this Jun 11, 2015
@Narretz Narretz closed this in 720012e Jun 16, 2015
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
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