10000 docs($provider): new example, more guidance on factory() vs service() by timruffles · Pull Request #4302 · angular/angular.js · GitHub
[go: up one dir, main page]

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

docs($provider): new example, more guidance on factory() vs service() #4302

Closed
wants to merge 1 commit into from

Conversation

timruffles
Copy link
Contributor

I was quite confused by $provide's documentation - it wasn't very explicit on which method (factory() vs service() etc) to use when, and the example given had no good reason to be a singleton.

I've updated the docs to be explicit. I've also provided a more real-world example that uses an injected service, and has a good reason to be a singleton.

It's not just me who's confused by $provide, so I thought it'd be good to make this page clearer.

I've made an external test for the new documented example.

@mary-poppins
Copy link

Thanks for the PR!

  • Contributor signed CLA now or in the past
    • If you just signed, leave a comment here with your real name
  • PR's commit messages follow the commit message format

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!

Currently $provide's example seems awkward. These examples are more real-world
- they use an injected service, and the service defined has a good reason to
be a singleton.
There's quite a lot of confusion around $provide, so I thought it'd
be good to make this page clearer.
Tests for example: http://jsbin.com/EMabAv/1/edit?js,output
Confusion on SO: http://stackoverflow.com/search?q=angularjs+service+vs+factory
@timruffles
Copy link
Contributor Author

Have signed CLA - Tim Ruffles.

@ghost ghost assigned petebacondarwin Oct 10, 2013
@petebacondarwin
Copy link
Contributor

@timruffles - thanks for this. I am going to build on what you have done here, if you don't mind.

@timruffles
Copy link
Contributor Author

Be my guest! Will it mean my commit gets in though? :)

@petebacondarwin
Copy link
Contributor

Sure :-)
On 10 Oct 2013 12:21, "Tim Ruffles" notifications@github.com wrote:

Be my guest! Will it mean my commit gets in though? :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/4302#issuecomment-26045405
.

@petebacondarwin
Copy link
Contributor

But it might be overwritten somewhat
On 10 Oct 2013 13:18, "Pete Bacon Darwin" pete@bacondarwin.com wrote:

Sure :-)
On 10 Oct 2013 12:21, "Tim Ruffles" notifications@github.com wrote:

Be my guest! Will it mean my commit gets in though? :)


Reply to this email directly or view it on GitHubhttps://github.com//pull/4302#issuecomment-26045405
.

@timruffles
Copy link
Contributor Author

That's fine - look forward to seeing changes :)

On 10 October 2013 13:22, Pete Bacon Darwin notifications@github.comwrote:

But it might be overwritten somewhat
On 10 Oct 2013 13:18, "Pete Bacon Darwin" pete@bacondarwin.com wrote:

Sure :-)
On 10 Oct 2013 12:21, "Tim Ruffles" notifications@github.com wrote:

Be my guest! Will it mean my commit gets in though? :)


Reply to this email directly or view it on GitHub<
https://github.com/angular/angular.js/pull/4302#issuecomment-26045405>
.


Reply to this email directly or view it on GitHubhttps://github.com//pull/4302#issuecomment-26048763
.

@petebacondarwin
Copy link
Contributor

@timruffles - I have fixed up your commit message and added a commit of my own on this branch. Can you take a look and comment? https://github.com/petebacondarwin/angular.js/compare/pr4302
Thanks

@timruffles
Copy link
Contributor Author

Nice! So much more helpful, ppl will be v glad when this is out.

On 10 October 2013 16:51, Pete Bacon Darwin notifications@github.comwrote:

@timruffles https://github.com/timruffles - I have fixed up your commit
message and added a commit of my own on this branch. Can you take a look
and comment? https://github.com/petebacondarwin/angular.js/compare/pr4302
Thanks


Reply to this email directly or view it on GitHubhttps://github.com//pull/4302#issuecomment-26065556
.

petebacondarwin added a commit that referenced this pull request Oct 10, 2013
Improve the "tracking" service example by adding a configuration option.
Get better formatting of the generated code samples using <pre> tags.
Move the detailed explanations into each function's documentation block.
Improve the overview and list the constituent functions by significance.

Closes #4302
@petebacondarwin
Copy link
Contributor

Landed. Thanks @timruffles

jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
Improve the "tracking" service example by adding a configuration option.
Get better formatting of the generated code samples using <pre> tags.
Move the detailed explanations into each function's documentation block.
Improve the overview and list the constituent functions by significance.

Closes angular#4302
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this pull request Jan 27, 2014
Improve the "tracking" service example by adding a configuration option.
Get better formatting of the generated code samples using <pre> tags.
Move the detailed explanations into each function's documentation block.
Improve the overview and list the constituent functions by significance.

Closes angular#4302
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.

3 participants
0