Let's say I want to get user information from firebase, and this user information will be displayed in several routes / controllers
Should I $rootScope return user information?
or
Call under code in each controller?
firebaseAuth.firebaseRef.child('/people/' + user.id).on('value', function(snapshot) { $scope.user = snapshot.val(); })
UPDATE
I have the following service with getUserInfo() function, then what is the best way to use it in multiple controllers? call firebaseAuth.getUserInfo().then() in each controller? If user data I have to use in several controllers. Why don't I install it with $rootScope ? Therefore, I do not need to call it again and again in different controllers.
myapp.service('firebaseAuth', ['$rootScope', 'angularFire', function($rootScope, angularFire) { this.firebaseRef = new Firebase("https://test.firebaseio.com"); this.getUserInfo = function(id) { var userRef = this.firebaseRef.child('/human/' + id); var promise = angularFire(userRef, $rootScope, 'user', {}); return promise; } });
vzhen source share