The parent directive goes through the compile command, pre and post before the child directive with templateUrl

So I have 2 directives, let's call them introductory and auto-complete.

The auto complete directive loads the remote template using templateUrl and includes the login. Autocomplete must be included in the input directive. Now the problem I'm running into is that the input directive is compiled and doing its function binding before auto complete compilation. This is a problem because the input directive assumes that there is an input element when the bind function is run, and because the bind function is executed before the auto complete command is compiled and DOM injected, the input directive does not find an input element.

I have to assume that compilation order, pre and post linking is not supported with downloading templates remotely due to the asynchronous nature.

Here is a plunker using no templates:

http://plnkr.co/edit/gEk3GjuASxrV1L6Kp6Dq?p=preview

The compilation functions, pre and post bindings are in the expected order. Then I try to do the same, but I have a directive logCompile2

that has a property template

:

http://plnkr.co/edit/EOYgf5z82mesixcb1LXU?p=preview

Again, the compilation functions, pre and post bindings are in the expected order. Finally, we have the directive logCompile2

with templateUrl

correct loading the template remotely:

http://plnkr.co/edit/A55sw6YRCuhvWUi6zQ4Q?p=preview

Now things don't work as expected, the parent parent directive now goes through all the steps before any steps are taken for the child directives. The only difference I can see between this version and the other version 2 is that the template is loaded remotely (and I assume it is asynchronous).

Is there anyway for the parent directive to wait for all child directives to compile and insert the DOM before running the parent bind function without having to inline templates?

+3


source to share


1 answer


Apparently this works as intended (you can start at this comment and read):



https://github.com/angular/angular.js/issues/8877#issuecomment-54129804

0


source







All Articles