-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Surprising behavior (and regression) when $compiling ngInclude directives #4505
Comments
repro yeah, that's not good Is the reason for this because of the inclusion of the comment element, which causes the ng-include template to not contain a single element? https://github.com/angular/angular.js/blob/master/src/ng/compile.js#L833 is where the comment is coming from, because of the
|
Your analysis is correct @caitp - the ng-include element is replaced by a comment. The contents of the include are then inserted "after" the comment. This should make little difference in most cases but if you are doing direct DOM manipulation you should be aware that there will now be two sibling elements. |
been a while since I wrote that one =) |
I am going to document this either in a testing section or in the $compile docs. |
Taking over this since Jeff is out (unless pete or caitlin want at it). |
$compiling a naked ng-include directive fails in 1.2.0-rc.*, although it has worked in earlier versions. In a test along the following lines:
where views/main.html is:
I get the following results, for v1.0.5, which works fine:
and the test passes, but for 1.2.0.rc-*:
the test fails, with the actual result being
''
instead ofSuper2
. Interestingly, the code works just fine in both versions if you surround the<ng-include>
directive with a naked<div>
.If this is an intended regression, I haven't seen any documentation (which doesn't mean its not there). Can you explain the reasons why this directive fails in current versions, while others do not, so I can anticipate the problem? Or should I simply make a routine practice of surrounding all code delivered to compile with a naked div?
The text was updated successfully, but these errors were encountered: