Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Inject authentication in rootScope instead of every child scope #1047

Closed
tmfelwu opened this issue Nov 5, 2015 · 2 comments
Closed

Inject authentication in rootScope instead of every child scope #1047

tmfelwu opened this issue Nov 5, 2015 · 2 comments

Comments

@tmfelwu
Copy link

tmfelwu commented Nov 5, 2015

Was there a specific reason that we are doing

$scope.authentication= Authentication 

in every scope, why not just do this once in run with $rootScope??

@mleanos
Copy link
Member

mleanos commented Nov 5, 2015

@sparshy I actually ended up injecting the $state service into my project's $rootScope. It made sense for me since my project started to get big.

For the case of the default MEANJS framework, it probably doesn't make sense to implement the Authentication service into the $rootScope, since the front-end is rather small.

If you find that your project is growing in size, and that you'd rather not inject your Authentication service into each controller/scope that needs it, then I don't see anything wrong with injecting it into your $rootScope. If it makes sense for your project.

@lirantal
Copy link
Member

Closing issue.

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

4 participants