I have this function inside my AngularJS controller. It looks like this;
polling_interval=1000;
var poll = function()
{
//Execution code
$timeout(poll, polling_interval);
};
poll();
It uses the $timeout service in AngularJS to keep calling itself. This works until I wanted to add parameters to this poll function. My code looks like this for the parameters added;
polling_interval=1000;
var poll = function(param1, param2)
{
//Execution code
$timeout(poll(param1, param2), polling_interval);
};
poll(param1, param2);
The syntax was not acceptable and I am at a loss now. How do I execute the function with parameters using $timeout in AngularJS? If this cannot be done, are there work-arounds to this problem? I would like to have my poll function accept parameters.
$timeout([fn], [delay], [invokeApply], [Pass]);. Documentation here