Thanks Emmanuel. But when i am on the same page, my query has to run 
continuously every 30 seconds. I only need it to stop when i navigate away 
from that page. 

On Sunday, August 2, 2015 at 2:29:54 AM UTC-5, Emmanuel DEMEY wrote:
>
> Hi Raju
>
> You should have a look to the "timeout" property of your "get" method.
>
> You can link this property to a promise that will stop your request when 
> resolved. 
>
> Manu
> @EmmanuelDemey
> Le 1 août 2015 19:32, "Srini raju" <[email protected] <javascript:>> a 
> écrit :
>
>> Hi,
>> I have an SPA and in one of the pages i have a chart that updates 
>> continuously using http.get through $interval. Unfortunately, it keeps 
>> running even when i go a different page/tab. How do i cancel the request 
>> when navigating away from the page. Appreciate any help.
>>  
>> .controller('myCtrl', function ($scope, $http, $timeout, $modal, 
>> $interval) {
>>             $scope.getData = function() { $http.get('
>> http://localhost:8080/getData?q=' + queries)
>>                 .success(function(data) {
>>                             console.log(data);
>>                 /* Business logic here */
>>             }).error(function (data, status){
>>                 console.log("Error status : " + status + " " + data);
>>             }) };
>>
>>            *promise = $interval($scope.getData, 3000);*
>> *}*
>>
>> *Thanks in advance for your help.*
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "AngularJS" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at http://groups.google.com/group/angular.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to