2014-03-13 16 views
1

모든 응용 프로그램에서 일부 데이터를 공유하기 위해 $rootScope 사용에 대한 토론을 읽었습니다.

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

어떤 사람들이 나쁜 관행이며, 우리는 데이터의 종류를 저장하기 위해 우리 자신의 서비스를 사용해야한다고 말했다.

나는 동의 할 의향이있다 : 나는 $rootScope 네이티브 서비스 AngularJS가 아닌가? 언제 $rootScope을 사용해야합니까?

답변

2

나는 상기 스레드에서 Kibsaim의 의견에 동의하십시오 $rootScope

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. 

퍼팅 객체는 자바 스크립트의 글로벌 네임 스페이스를 오염하는 나쁜 같은 방법으로 장기적으로 좋지 않습니다.

관련 문제