I like this approach! 
But the question is, at what point in my code should i emit the event  
scope.$emit('widgetsAreShuffled') ?

If i do this in controller just after I modified my widgets list, can I be 
sure that my widget directive recieves it AFTER the actual DOM 
modifications by ng-repeat and not immediately? 
Will scope.$emit() wait till the end of current digest cycle?

$scope.shuffleWidgets = function() { 
        // Change the order of widgets to [widget2, widget1] 
        $scope.widgets[0] = [widget2]; 
        $scope.widgets[1] = [widget1]; 

        scope.$emit('widgetsAreShuffled'); // <----   Can i be sure that 
directive recieves this event AFTER the DOM is modified by ng-repeat ?
}

On Thursday, February 20, 2014 12:04:51 PM UTC+4, Sander Elias wrote:
>
> Ivan,
>
> So the ‘reshuffeling’ is under control of your code. Then it’s easy 
> enough. In your code, do a $scope.$emit('widgetsAreShuffled')
> In your directive link function something like:
>
>   scope.$on('widgetsAreShuffled', function () {
>      // re-init your tiny-MCE
>   });
>
> if you need a start and stop event, that’s a bit more work, and you need 
> to make sure that there is a digest cycle after your start event, but 
> before you actually do anything.
>
> Hope this helps a bit?
> Regards
> Sander
>

-- 
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/groups/opt_out.

Reply via email to