mgibas
mgibas

Reputation: 408

Angular directive template is not compiled by outer directive

I have simple tags:

<form show-errors>
    <date-input />
</form>

as You can imagine I have two directives: showErrors and dateInput.

showErrors should work on DOM that is loaded by dateInput template but that never happens :( showErrors runs (DOM is empty) and after that dateInput loads its template but it's way too late. I have impresion that im using directives in wrong way :(

Please take a look at my plunker for details: http://plnkr.co/edit/3QEd1HvJETo30tZd1zl3

Update: I updated my plunker and it seams that it's all about lazy loaded template from URL. Any ideas how that should be solved in angular clean way ?

Upvotes: 0

Views: 103

Answers (2)

bengro
bengro

Reputation: 1014

You're making two mistakes.

First, your inner directive should be named dateInput:

app.directive('dateInput', function() {

Second, you need to explicitly close the date-input tag.

<date-input></date-input>

It's important to note, that the AngularJS compiler does cannot parse

<date-input />

Upvotes: 1

Kamil R
Kamil R

Reputation: 447

First of all you have a typo in the directive's name: instead of dateinput there should be dateInput.

However, it is impossible to refer to the children from the parent in directives. Only communication in the other direction is allowed (usually using controllers).

Upvotes: 1

Related Questions