Hi ,

Is there a way I can cache compiled templates of an Angular JS directive ? 
I am trying something like this :

if (DirectivesCache.containsKey(key)) {
                                        var cachedTemplate = 
DirectivesCache.getValue(key);
                                        cachedTemplate(scope, function 
(clonedElement: any, scope: any) {
                                                        
element.append(clonedElement);
                                                });
                                } else {
                                        // when the 'render' expression changes
                                        // assign it into the current DOM
                                        
 
                                // compile the new DOM and link it to the 
current
                                // scope.
                                // NOTE: we only compile .childNodes so that
                                // we don't get into infinite loop compiling 
ourselves
                                        var retObj = 
$compile(element.contents());
                                        DirectivesCache.add(key, retObj);
                                        retObj(scope);
                                }



But this does not produce correct result . Basically I am caching the partial 
result of a compiled directive and linking it to

current scope via *cloneAttachFn 
<http://docs.angularjs.org/api/ng/service/$compile#usage>. *But somehow this 
technique doesn't work and throws angular exception when the cached template is 
rendered in DOM.


Any pointers here would be appreciated . Stuck here for a long time now 





-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" 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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to