Monday, 31 March 2014

Value is not updating in IE-8 - Angular js

I have faced an issue while using angular service, that is value is not updating in IE-8

On click of add new button I am calling a rest service and displaying the response in a table. It has an edit option in each row , what is happening in IE-8 is that after saving edited data it is still showing the old data .It is working fine in all other browsers .

My code that is not working in IE-8

Most of the time i was not able to get the updated value in IE-8

 
getUsers: function(data, success, error)
{ 
 var url = var url = '/your web service path';;
 
 $http.get(url)
  .success(function(data, status)
  {
   success(data);
   
  })
  .error(function(data, status)
  {
   error(data);
   
  });
}

 

Code that worked in all browsers

I have changed this to below code and it started to works in IE-8 also.

 
getUsers: function(data, success, error)
{ 
var url = '/your web service path';

//Added this
var fetch_timestamp = function() { return parseInt
 (new Date().getTime().toString().substring(0, 10))};

// or  
// var currentTime = new Date().getTime();

var timestamp = fetch_timestamp();

url = url + '&t='+timestamp;

$http.get(url)
 .success(function(data, status)
 {
  success(data);
  
 })
 .error(function(data, status)
 {
  error(data);
  
 });
}

 

This piece of code fixed my issue.

 
var url = '/your web service path';

//Added this
var fetch_timestamp = function() { return parseInt
 (new Date().getTime().toString().substring(0, 10))};

// or  
// var currentTime = new Date().getTime();

var timestamp = fetch_timestamp();

url = url + '&t='+timestamp;
 

But I am not sure this will be the right fix .I thought to share this because it may help to somebody .If you are thinking this is a wrong fix please add a comment or give a referral link.

Related Posts

1. Save highchart as binary image

2. Communicate with controllers in angular js

3. Angular routing

4. Rating Stars using angular js Directive concept

5. Loop concept in angular js

6. Filtering concept in angular js


No comments :

Post a Comment