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

scope.$service docs needs parens #341

Closed
arantius opened this issue May 9, 2011 · 4 comments
Closed

scope.$service docs needs parens #341

arantius opened this issue May 9, 2011 · 4 comments
Milestone

Comments

@arantius
Copy link
Contributor

arantius commented May 9, 2011

http://docs.angularjs.org/#!angular.scope.$service

This page says:

Usage

1 angular.scope.$service(serviceId);

But it needs to say angular.scope().$service(serviceId);. (Note missing parens.)

@IgorMinar
Copy link
Contributor

actually it should say something like:

scope.$service(serviceId)

where scope is some angular scope.

angular.scope() creates a new root scope and a new instance of the service, which you only rarely want to do.

@arantius
Copy link
Contributor Author

Ok, agreed. I think calling angular.scope() was actually causing us some
problems. There's a few places in the docs that suggest this, but it seems
to subtly break things. What's the right way to get a reference to the
already-existing root scope? And could I please suggest that the docs are
updated to clearly reflect this. Thanks in advance.

On Mon, May 9, 2011 at 8:54 PM, IgorMinar <
[email protected]>wrote:

actually it should say something like:

scope.$service(serviceId)

where scope is some angular scope.

angular.scope() creates a new root scope and a new instance of the service,
which you only rarely want to do.

@IgorMinar
Copy link
Contributor

if you have any scope reference you can either call $service directly on it, or if you do want explicit root scope reference you can do scope.$root. if you don't have a reference to any scope (very rare, maybe when debugging an app in production via browser), then you can retrieve it with as follows: angular.element(htmlOrRootElementOfYourApp).scope().

I'll add a mention of this into the scope docs

@btford
Copy link
Contributor

btford commented Aug 24, 2012

$service doesn't seem to exist anymore, but some of what is mentioned here might be worth adding to the docs (getting at a scope with angular.element().scope(), for instance). I'm going to close this, but if you think it's worth revisiting, feel free to re-open it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants