You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
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.
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().
$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.
http://docs.angularjs.org/#!angular.scope.$service
This page says:
But it needs to say
angular.scope().$service(serviceId);
. (Note missing parens.)The text was updated successfully, but these errors were encountered: