How to autorefresh a widget for each 5seconds?

sana11
Kilo Guru

Hi guys.I am trying to auto refresh the widget for each 5 seconds without refreshing the page.

I have tried the following client script,but it works only on page load not refreshing automatically for each 5 seconds.

 

function($scope,$timeout,spUtil) {

var c = this;
$timeout(function(){
spUtil.update($scope);
alert();
}, 5000);
}

 

If I use the `$interval` with `$scope.reload` instead `spUtil.update($scope);` I am getting an error `$scope.reload is not a function`.But it throws alert for each 5 second.

function($scope,$timeout,$interval,spUtil) {

var c = this;
$interval(function(){
//$scope.reload();
alert();
}, 5000);
}

 So how can I auto refresh a particular widget?

Any help? Thanks!!

1 ACCEPTED SOLUTION

sana11
Kilo Guru

Guys got solution.

 

function($scope,$timeout,$interval,spUtil) {

var c = this;
$interval(function(){
console.log("------working------")
spUtil.update($scope);
}, 3000);
}

View solution in original post

5 REPLIES 5

Yes, Thats why I have used $timeout.But it does't work for me.

Please check my updated question.

 

sana11
Kilo Guru

Guys got solution.

 

function($scope,$timeout,$interval,spUtil) {

var c = this;
$interval(function(){
console.log("------working------")
spUtil.update($scope);
}, 3000);
}