Refactoring of task events using $scope.$emit