Gly Jones
Gly Jones

Reputation: 99

AngularJS "global" data?

I'm creating a web app with angular. Users can log in and send messages to other users.

What's the best way of globally storing information about the logged in user - e.g. their username, ID, picture URL, etc? Or do I need to send it as part of the JSON data used to render each page?

Upvotes: 3

Views: 2492

Answers (1)

Dogoku
Dogoku

Reputation: 4675

The "Angular" way to do this, is to use something called a Service

See this video by the amazing John Linguist, for more information on how to achieve this

http://egghead.io/video/angularjs-sharing-data-between-controllers/

Upvotes: 4

Related Questions