Hi everybody, I'm trying to use $scope.$on and $rootScope.$broadcast in
order to use a variable of a controller function in another controller
function. I have already use this for other purpose, so my issue is the
$scope.$on function isn't executing, I tried to make alert inside it but I
didn't get any alert, I don't know what is the problem. Here is a snippet
of my code to illustrate the issue. Thankx for advance :)
app1.controller('autoCompleteCTRL',function($scope,$rootScope,$http) {
$scope.$on("myEvent3", function (event, args) {
alert(1);
$scope.SearchNearPoint= args.value;
$http({
method: "get",
url: "path/to/file.php",
dataType: 'json',
params: { 'userText': $scope.searchText},
async: false
}).success(function(data, status, headers, config) {
$rootScope.suggestions = data;
}).error(function(data, status, headers, config) {
});
});
app1.controller('BasicCenterController', function($scope, leafletData,$http)
{
$scope.$root.$broadcast("myEvent3", {
value: startLatLng
});
});`
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.