Hi All,
I think I'm running into a digest cycle problem, and I'm wondering what the
best practice is for what I need to do.
Here's some code snippets for what I'm doing:
*I have repeating streams with repeating canvases layered on top of them,
all bound to a single data structure*
<div ng-repeat="stream in streams track by $index">
<canvas my-canvas draw="draw" ng-repeat="draw in stream.draw track by
$index"></canvas>...
*Then I have a function to clear the stream data structure and repopulate
it. The my-canvas fills in some of the data structure when it receives
'updatecss' so I can have pointers to the dom elements without having to
relay everything in my controller through to the directive. (I understand
this may not be best practice, but it seems to be very fast).*
$rootScope.streams = [];
var streams = JSON.parse(layout.data);
$timeout(function()
{
for(var j = 0; j < streams.length; j++)
{
streams[j].index = j;
$scope.addStream(streams[j]);
}
$rootScope.render.layout = layout;
console.log(layout.name + ' layout loaded');
$rootScope.$broadcast('updatecss');
}, 5);
So basically my problem is that I have to clear the array
($rootScope.streams) and then wait for the ng-repeat to clean out all the
DOM objects, and then I can repopulate it. Obviously a $timeout is a bit
of a nasty hack at this stage. Is there a clean way of saying "Do this
after the next digest cycle"?
Thanks!
Leighton.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.