Within my AngularJS controller, I have a function that looks like this;
polling_interval=1000;
var poll = function()
{
//Execution code
$timeout(poll, polling_interval);
};
poll();
This function uses the $timeout
service in AngularJS to call itself continuously. However, when I tried adding parameters to the function, it resulted in an error. Here is the code with added parameters;
polling_interval=1000;
var poll = function(param1, param2)
{
//Execution code
$timeout(poll(param1, param2), polling_interval);
};
poll(param1, param2);
The syntax used for adding parameters was not correct and now I am unsure about how to proceed. Is there a way to execute the function with parameters while using $timeout
in AngularJS? If not, are there any alternative solutions to allow my poll function to accept parameters?