ngInclude behavior change from 1.2.1 -> 1.2.2 #5247
Description
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);
}
};
});