-
Notifications
You must be signed in to change notification settings - Fork 27.4k
docs($provider): new example, more guidance on factory() vs service() #4302
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with 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
Have signed CLA - Tim Ruffles. |
@timruffles - thanks for this. I am going to build on what you have done here, if you don't mind. |
Be my guest! Will it mean my commit gets in though? :) |
Sure :-)
|
But it might be overwritten somewhat
|
That's fine - look forward to seeing changes :) On 10 October 2013 13:22, Pete Bacon Darwin notifications@github.comwrote:
|
@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 |
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:
|
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
Landed. Thanks @timruffles |
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
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
I was quite confused by
$provide
's documentation - it wasn't very explicit on which method (factory()
vsservice()
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.