Finally sifted through all that $rootScope.$apply() stuff. WARNING: CONTENTS UNDER PRESSURE