Thanks Daniel.

I spent 2 hours today exploring "compile" option.   You are right.   By
using compile option on custom directive, the directive runs from outer
node to inner node.

But the "compile" function has limitation.   I need scope.$watch in my
directive.  The "compile" function cannot access that.

Thanks.

Ian


On Thu, Jan 2, 2014 at 9:52 PM, Daniel Tabuenca <[email protected]> wrote:

> Well, the compile function gets called from outer to inner, the link
> function gets called in reverse order. Whether the html is dynamically
> loaded or not should not affect the outcome. See for example this test:
>
> http://plnkr.co/edit/KaeJv1Em5A6RhnvkowUC?p=preview
>
> It would be best if you could give us a more concrete example of what you
> are actually trying to accomplish. If you could make a plunker I can help
> you explain what's going on and what the best way to do what you are trying
> to do might be.
>
>
>
>
> On Thursday, January 2, 2014 5:36:54 PM UTC-8, Ian Zhang wrote:
>
>>  Thank you for the reply.
>>
>> For dynamically loaded partial view, from console log, I found the custom
>> directive apply to inner node (div in my case) first, then goes to outer
>> node.   For normal index.html file, it is from outer node to inner node.
>> I don’t know why.
>>
>> I have nested div components and with same directive.   I want to apply
>> the directive from outer div node to inner div node.
>>
>> Thanks.
>> Ian
>>
>> *From:* Daniel Tabuenca
>> *Sent:* Thursday, January 02, 2014 6:03 PM
>> *To:* [email protected]
>>
>> Angular starts at the root node of the application (where ng-app is) and
>> goes down the tree node-by-node. For each node it encounters it tries to
>> determine all the directives that are on that node. If it finds multiple
>> directives on one node it will order them by greatest to least priority
>> (you can define priority on your directive). It then will iterate over the
>> children of the node and repeat the process.
>>
>>
>> On Thursday, January 2, 2014 2:01:05 PM UTC-8, Ian Zhang wrote:
>>>
>>> Hi Everyone
>>>
>>> I have defined some custom directives.   Is there a definite sequence
>>> when they run?   Which one will run first?   Can I define the running
>>> sequence?
>>>
>>> Thanks,
>>>
>>> Ian
>>>
>>>
>>>
>>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "AngularJS" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/
>> topic/angular/jijWCUUQ3wg/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/groups/opt_out.
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/jijWCUUQ3wg/unsubscribe.
> To unsubscribe from this group and all its topics, 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/groups/opt_out.
>

-- 
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/groups/opt_out.

Reply via email to