Trigger Refresher


#1

I’m trying to figure out how to cause the refresher to trigger programatically. For example, a user does something that updated the backend. I need to trigger a refresh.

I don’t see anything in the code for actually triggering the effect. I can imagine something like triggering a Gesture, but that code is over my head. Suggestions?

Thanks,
Justin


#2

Never mind. I found the smarter way to do this. My model should be updating when the cache gets refreshed in my service. So, now that I’m properly doing this, my list updates automatically.


#3

Hi Calandee , can u provide a demo link for auto refresh of data from json without pull to refresh.
it has to update the value every 30 sec.


#4

I’ve been using angular-cache and having the cache expire every 30 seconds. It supports an onExpire callback that lets me update the cache in the background. I use $rootScope.$broadcast in the cache call back to let my controller know there’s updated data. I then use $scope.$on to listen for that broadcast on my controller to let it know it needs to fetch new data.

Sorry, I know you asked @Calendee, but I wanted to share my 2 cents and possibly get feedback.

Thanks,

Jared


#5

Thanks dear @compudaze could you share the demo in codepen.

If any one else has a option , could you plz share


#6

The key here is that the refresher is not really responsible for this task. You controller &/or service should be doing this.

Here’s a VERY rough demo of doing this. Ideally, this should be done in a service instead of the controller as @compudaze suggested.


#7

HI @Calendee , actually i’m loading a data from json using

	function TeamsCtrlAjax($scope, $http)
	{
	$http({method: 'POST', url: 'js/teams.json'}).success(function(data) {
	$scope.teams = data;
	});
	}

if i update my json data , it has to be reflected in the client side.

Any suggestions ,?

Thanks in advance


Ionic Refresh
#8

And that should work just fine like in my example.

However, I think I see your problem. You are not using “dot notation”. Try changing $scope.teams = data to $scope.data.teams = data and then updating your binding in your HTML.