So, I have a classic angular problem, where my app includes a large table 
generated by nested ngRepeats.  Of course, this results in thousands of 
watch expressions, or rather (rows x columns x cell) watch expressions. 
 The per-cell rendering isn't that complicated - just some ng-ifs, ng-url, 
and regular bindings.  Of course, I could use the one-way bindings from 
1.3, but that doesn't help with the ng-ifs and the ng-urls.

However, it turns out I really only have three values I need to watch. 
 Each table is a combination of visible rows, visible columns, and a date 
range identifying the dataset.  So, ideally, I'd only have watchers for 
these three values and update the whole table when they change.  I got part 
of the way there by creating a directive for each table row.  This 
directive watches the selected dataset and the list of visible columns, and 
rebuilds the row when either of those change.  I build up the html for each 
cell programmatically, then concat them and update the innerHTML for the tr 
in a single pass.  

This is a reasonable improvement in performance - I've gone from 1.7s to 
update the page to about 500ms, with most of that time being rendering and 
layout.  However, to do this I've had to give up other directives and 
angular templating.  What I'd really like to do is describe my table using 
regular templates and directives, but have a custom directive at the table 
level that removes all watch expressions on child scopes and replaces them 
with it's own.  This would allow me to use ng-if and other directives to 
render my table, but only update the table as a whole when the relevant 
variables change.

Has anyone done this before?  I'm not entirely clear on how I could remove 
watch expressions from child scopes, or how I would make sure that the 
table renders properly initially before those watches are removed.  Am I 
just barking up the wrong tree here?

-- 
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.

Reply via email to