Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Callback function on a $scope.broadcast?

$
0
0

@zocheyado wrote:

So I am trying to use a callback function and it is working everywhere else in my code for example.

//calling a function
$scope.someFunction(function(){
console.log('this will output second');
})
//function definition
$scope.someFunction = function(retFunct){
console.log('this will output first');
retFunct();
};

This code works everywhere I use it. Except I have a function inside a directive so I am using the command.
$scope.$broadcast('myFunction');

This will run my function like normal, but if I try to do a callback function on that event, and put the exact some logic in the function as I did in $scope.someFunction I get the error retFunct is not a function.
$scope.$broadcast('myFunction', function(){
console.log('this will output second");
};

So my questions are 1, is there a better way to call a function inside of a directive besides $scope.$braodcast? 2, if not is there a way to make a callback function work inside of $scope.$broadcast.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles