I have a controller and want to pass a value of a scope to another.
app.controller("ChatController", function($scope, $firebaseArray, $timeout, $firebaseAuth, $window) {
var ref = firebase.database().ref().child("messages");
var auth = $firebaseAuth();
$scope.messages = $firebaseArray(ref);
$scope.sendMessage = function() {
//var firebaseUser = $scope.firebaseUser;
$scope.messages.$add({
text: $scope.newMessageText,
current_time: new Date().toJSON()
});
$scope.newMessageText = null;
};
$scope.login = function() {
$scope.firebaseUser = null;
$scope.error = null;
auth.$signInWithPopup('google').then(function(firebaseUser) {
$scope.firebaseUser = firebaseUser; //access this to the sendMessage scope
console.log(firebaseUser.user);
}).catch(function(error) {
$scope.error = error;
});
};
});
Above me, I have sendMessage and login scope. I want to pass the value of $scope.firebaseUser to the login scope. Is that possible?