Organizational Research By

Surprising Reserch Topic

angularjs how to run additional code after angularjs has rendered a template


angularjs how to run additional code after angularjs has rendered a template  using -'javascript,jquery,dom,angularjs'

I have an Angular template in the DOM.  When my controller gets new data from a service, it updates the model in the $scope, and re-renders the template.  All good so far.

The issue is that I need to also do some extra work after the template has been re-rendered and is in the DOM (in this case a jQuery plugin).

It seems like there should be an event to listen to, such as AfterRender, but I can't find any such thing.  Maybe a directive would be a way to go, but it seemed to fire too early as well.

Here is a jsFiddle outlining my problem: Fiddle-AngularIssue

== UPDATE ==

Based on helpful comments, I've accordingly switched to a directive to handle DOM manipulation, and implemented a model $watch inside the directive.  However, I still am having the same base issue; the code inside of the $watch event fires before the template has been compiled and inserted into the DOM, therefore, the jquery plugin is always evaluating an empty table.

Interestingly, if I remove the async call the whole thing works fine, so that's a step in the right direction.

Here is my updated Fiddle to reflect these changes: http://jsfiddle.net/uNREn/12/
    
asked Sep 24, 2015 by yashwantpinge
0 votes
4 views



Related Hot Questions



Government Jobs Opening


...