Set Event:
$timeout(function() {$rootScope.$broadcast('userCountry', value);}, 500);
Get Event:
$scope.$on('userCountry', function(event, userCountry) {console.log(userCountry + '----userCountry');c.searchLoc = userCountry;});References:
https://serviceportal.io/using-events-communicate-widgets/------------------------------------------------------------------------------
$emit: Child to Parent
Set Event:
function($rootScope, $scope) {var c = this;c.selectNote = function(number) {$rootScope.noteID = number;$rootScope.$emit('selectNote', number);}}
Get Event:
function($rootScope, $scope) {
var c = this;
$rootScope.$on('selectNote', function(event, data) {
return $rootScope.noteID;
});
}