Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have updated your code so that it does what I think you want (at a minimum this works the way your old code does, but under rc3 as you wanted): <a href="http://plnkr.co/edit/nsq4BGAih3lfNmS2mLP7?p=preview" rel="nofollow">http://plnkr.co/edit/nsq4BGAih3lfNmS2mLP7?p=preview</a></p> <p>But I made quite a few changes and a significant architectural change so let me know if this moves away from the spirit of what you're trying to achieve.</p> <p>I think the gist of the issue was that your two directives (<code>generic</code> and <code>specific</code>) were tightly coupled around <code>contentVisible</code> which created a complex dependency that resulted in you having to very carefully manage invocation timing. My approach was to <strong>decouple the two directives</strong>- encapsulating <code>contentVisible</code> within <code>generic</code>. This allows <code>generic</code> and <code>specific</code> to instantiate fully independently. So you're not dependent on any invocation timing. And <strong>thus the directive priority change no longer has any impact on this code</strong>. So, one big win with the solution I propose is it should be robust against further changes by the Angular team.</p> <p>Specifically, I moved the template in to the same directive (<code>generic</code>) as the controller which manages <code>contentVisible</code> . This way the <strong>controller that changes <code>contentVisible</code> lives on the same scope as the template which uses it</strong>.</p> <p>Now <code>specific</code> just calls over to the <code>required:</code> <code>generic</code> controller to toggle visibility (effectively as a setter function).</p> <p>I also moved the <code>ng-class</code> assignment into the template in order to encapsulate that change within one place (the template) and so you don't need jquery or a <code>link:</code>/<code>compile:</code> on <code>generic</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload