nside one of the directive I have this

myApplication.directive('direc', ['$compile', '$http', '$templateCache', 
'navigationService', function($compile, $http, $templateCache, 
navigationService) {    
scope.getScope = function(name) {
                console.log("in passScope method");
                navigationService.broadcast(name, 
scope.content,scope.headerLabel);               
            };
}

And I have one Service which have brodcast method

myApplication.factory('navigationService', function($rootScope) {
    var navigationService = {};
        navigationService.broadcast = function(name, object,headerLabel) {
            navigationService.object = object;      
            if(object.id)
            {
                navigationService.selectedElementId = object.id;
            }       
            $rootScope.$emit(name);
        };
        return navigationService;});

And I have two controller which contains $rootScope.$on method.

myApplication.controller('childController', ['$scope', '$http', 
'navigationService','$rootScope',
                                             function ($scope, $http, 
navigationService,$rootScope) {

    var cleanUpFunc = $rootScope.$on('leftSideClick', function() {
        // some logic.....}});

This controller is a child controller of the above controller.

myApplication.controller('subChildController', ['$scope', '$http', 
'navigationService','$rootScope',
                                             function ($scope, $http, 
navigationService,$rootScope) {

    var cleanUpFunc = $rootScope.$on('tabDisplay', function() {
        // some logic.....}});

And i have two more controller one is root controller and one is left 
controller,root controller is a parent controller for all the controllers.

Now, this is a single-page app and page contains 10 links.I am calling 
function getScope('tabDisplay') on click event of a link , 
subChildController $on function executed once and when i click on some 
other link which have getScope('tabDisplay').$on function will executed 
twice.... If I do it again, it happens three times and so on. What am I 
doing wrong here? I got the solution from this link AngularJs broadcast 
repeating execution too many times 
<http://stackoverflow.com/questions/19553598/angularjs-broadcast-repeating-execution-too-many-times>

but it is not wokring in my case.Please Advice.

-- 
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 http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to