I got it working eventually, as I mentioned above. It took me forever to
debug a problem with caching the precompiled dom by storing the result of
the transclude function. It is some kind of jquery wrapper and refuses to
behave the way I expect.
In the end I had to store it as angular.element("<div/>").append(clone).html
()
Thanks Sander!
On Friday, April 24, 2015 at 12:55:40 PM UTC-4, Brian wrote:
>
> Ah I see what you're saying. It might get messy, agreed.
> I think I was able to achieve what you're saying but without the toggle.
>
> I failed to mention this earlier but I have a UID for each of these
> rootDirective elements, so I can store the precompiled version exactly per
> unique (rootDirective) dom element.
> I changed my root directive's dom "wrapping" algorithm to wrap only the
> enabled directives
> Then I trigger the recompile externaly and pass the cached precompiled
> content, which re-fired the root directive on the original content and
> wraps it in the NEW set of enabled directives.
>
> Still in early testing, but it looks like it will be working...
> Will post results when done
>
>
> On Friday, April 24, 2015 at 12:28:27 PM UTC-4, Sander Elias wrote:
>>
>> Brian,
>>
>> Ok, I see what you are trying to do. I'm not sure if this is a good idea
>> to begin with. Let me first state that it is possible, with plain JS and
>> some angular. No jQuery needed at all.
>> There are a couple of things that needs to be done.
>>
>> 1. create an toggle directive that you add to each one you want to
>> toggle.
>> 2. run that at a higher priority, and make it terminate.
>> 3. when terminated, save the innerHTML to a temp storage.
>> 4. check if the direcive is enabled, if so compile what you have
>> 5. if not, take out the direcive, and then compile.
>> 6. rinse and repeat.
>>
>> Be aware that this will involve lots of edge-cases and pitfalls. There is
>> no simple solution, and the nesting of the directives doesn't make it
>> simpler.
>> I'm pretty sure, that your use-case is solvable in a couple of other ways
>> that are less error-prone and don't for starterts, a couple of ngIfs in
>> your template will come a long way.
>>
>> 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/d/optout.