Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngInclude behavior change from 1.2.1 -> 1.2.2 #5247

Closed
@matthughes

Description

@matthughes

If you have a directive on an ng-include attribute, it appears the content is not loaded prior to executing your directive's link function. In 1.2.0 and 1.2.1, the following code would have children().length == 1. In 1.2.2, the content doesn't get included until after this directive is executed. I tried setting the priority of my directive but it still gets invoked before the template has been loaded.

What is the expected behavior here? Is it defined? Do I just need to add an onload event handler in case the child gets loaded subsequent to my directive's link function being called? (I tried running this in post-link but behavior was the same).

// Full plunkr showing the problem. Just change angular version.
http://plnkr.co/edit/VWA0JTcpNDoNZkTrmllA?p=preview

<ng-include my-custom-directive src="'myTemplate.html'"></ng-include>
app.directive('myCustomDirective', function() {
    return {
      restrict: 'A',
      link: function(scope, element, attrs) {

        window.alert(element.children().length);

       }
     };
   });

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions