Callback for after Angular has updated the DOM after a $scope variable change.

845 views
Skip to first unread message

Raj Sekharan

unread,
Apr 16, 2013, 4:39:58 AM4/16/13
to ang...@googlegroups.com
I'm currently developing a DOM heavy application that uses angularjs. I need to add event handlers to individual elements in a ngrepeat. The ngrepeat is bound to a array that could change based on user action. I need to be able to get a notification after angular finishes the updates for the DOM so that I can do come actions on the new elements in the scope. is it possible to do this?

paweł kamiński

unread,
Apr 16, 2013, 5:29:19 AM4/16/13
to ang...@googlegroups.com
I dont think angular has something like that build in, but you could extend ngRepeat (I know this is a big chunk of code)

Raj Sekharan

unread,
Apr 16, 2013, 5:37:03 AM4/16/13
to ang...@googlegroups.com
I need it not just for ngRepeat but generally to get notification when a $scope property changes the DOM. Even a single variable binding should be listenable. Are there any alternatives to modifying Angular core. 

Alan Hampson

unread,
Apr 16, 2013, 11:26:41 AM4/16/13
to ang...@googlegroups.com
ngView has a $viewContentLoaded event. (fires when the content is reloaded)

Is this of any help? I'm not completely following your use case here.

Alain Chautard

unread,
Oct 2, 2014, 8:05:20 PM10/2/14
to ang...@googlegroups.com
You can use $timeout(function() { .... your code here ...}); whcih will basically run your specific code once the DOM has finished rendering.

Tony pee

unread,
Oct 3, 2014, 1:06:21 PM10/3/14
to ang...@googlegroups.com

--
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 angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.



--
Tony Polinelli

Reply all
Reply to author
Forward
0 new messages