Angular Phonegap/Cordova and resume event

1,152 views
Skip to first unread message

sc...@eade.id.au

unread,
Oct 9, 2012, 9:24:29 PM10/9/12
to ang...@googlegroups.com
I am building an iOS app using Angular in conjunction with Phonegap/Cordova.  One of the things I need to do is to deal with the situation where someone switches to a different app then returns to my app.  To do this my app listens for the resume event thus:

    document.addEventListener('resume', $scope.resume, false);

$scope.resume appears to be invoked correctly when the user returns to my app, but any updates it makes that ought to be reflected on the page are not.

  $scope.resume = function() {
      var now = new Date();
      console.log('resumed at ' + now); // log statement is output as expected
      $scope.counter = 0; // value of $scope.counter is updated, but the pages reference to it is not
  };

So after executing upon resume, $scope.counter is 0, but this is not reflected on the page.

Is there something I would need to do in my resume function to somehow trigger Angular to update the page content?

Thanks,

Scott

Andy Joslin

unread,
Oct 9, 2012, 10:32:16 PM10/9/12
to ang...@googlegroups.com, sc...@eade.id.au

sc...@eade.id.au

unread,
Oct 9, 2012, 10:44:46 PM10/9/12
to ang...@googlegroups.com
I had a feeling there was an apply() somewhere in the answer.  Works like a charm.  Thanks.

On Wednesday, October 10, 2012 1:32:16 PM UTC+11, Andy Joslin wrote:
Try $scope.$apply().  http://docs.angularjs.org/api/ng.$rootScope.Scope#$apply
Reply all
Reply to author
Forward
0 new messages