1

I was reading a discussion about using $rootScope to share some data across all application.

http://www.linkedin.com/groups/Using-rootScope-store-data-5010991.S.5848794319187644420?view=&srchtype=discussedNews&gid=5010991&item=5848794319187644420&type=member&trk=eml-anet_dig-b_pd-ttl-cn&fromEmail=&ut=36igDbZcDcIC81

Some people said that this is a bad practice, and that we should use our own services to store that kind of data.

Although I'm willing to agree, I have a question: isn't $rootScope a native service of AngularJS? When should I use $rootScope then?

1 Answer 1

2

I agree with the comment of Kibsaim in the said thread:

Hello Carla, 

I will recommend not overloading rootScope, although what you comment can be done, I will       
recommend you using a service with state, and inject it over controllers to share the   
information. 

That should be cleaner on the long run.

Putting objects in the $rootScope is bad in the long run in the same way that polluting Javascript's global namespace is bad.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.