AngularJS and AJAX - angular is not updating / refreshing

if u'll try to make an AJAX based angluar app u'll run in a few problems of data not updating right.

thats becuz the $http.get/post runz async and ur controllers and direcitves finish their jobs, and even if u call them again sometimes its not enough.

so 1st thing is to use some broadcasting, in the service family there is $rootScope.$broadcast('eventName'); the controllers use  $rootScope.$emit('eventName'); and u can even send args with them.

then in the controllers / directives u should do this:
scope.$root.$on('eventName');

with DOM manipulation directives do:
scope.$root.$on('eventName', function(){
  $timeout(function () {
     //code
  });
});

this is a kind of 'onDigestComplete'.

Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

Asp.Net Ending Response options, Response.End() vs CompleteRequest()