Working with $scope.$emit and $scope.$on

前端 未结 12 1237
花落未央
花落未央 2020-11-21 15:22

How can I send my $scope object from one controller to another using .$emit and .$on methods?

function firstCtrl($scop         


        
12条回答
  •  -上瘾入骨i
    2020-11-21 15:38

    This is my function:

    $rootScope.$emit('setTitle', newVal.full_name);
    
    $rootScope.$on('setTitle', function(event, title) {
        if (scope.item) 
            scope.item.name = title;
        else 
            scope.item = {name: title};
    });
    

提交回复
热议问题