I have a code to authentication where I want call an event after receive some data, but "$scope.$emit" not working in the callback of "User.me()" and I not understand.
Anybody can explain me?
$scope.login = function () {
OAuth.getAccessToken($scope.user).then(function () {
$scope.$emit('event:here:work');
User.me({}, {}, function (data) {
$scope.$emit('event:here:NOT-WORK');
});
$scope.$emit('event:here:work');
}, function (response) {
// error //
});
};
I try:
$scope.$emit('event'); // but, not work
$scope.$broadcast('event'); // but, not work
$rootScope.$emit('event'); // but, not work
$rootScope.$broadcast('event'); // work!!!!
Now, the "why" I not know?