$compile return wrong $element
Start with 1.2.0 version
$compile("<div ng-controller="controller" data-ng-include="templateUrl"></div>")($scope);
return wrong $element in controller.
$element is Object Comment(data: " ngInclude: templateUrl ").
Did you retype the code example? Because you haven't escaped the inner double-quotes or used single quotes:
$compile('<div ng-controller="controller" data-ng-include="templateUrl"></div>')($scope);
Off cause code is
$compile('<div ng-controller="controller" data-ng-include="templateUrl"></div>')($scope);
If i add ng-include as child element all ok.
$compile('<div ng-controller="controller"><div data-ng-include="templateUrl"></div></div>')($scope);
This functionality is by design. This is a quote from Angular's source. "using ng-include on an element with additional content does not make sense..." ngInclude trancludes the entire 'element' and replaces the transcluded clone with an element that is directly correlated to the template ngInclude fetches from the http request. This means the the orignal element is not relevant anymore once ngInclude is added to a DOM node.
it's hard for me to judge from this what the actual issue is. we tweaked ngController+ngInclude priorities to ensure that ngController runs before ngInclude and so that we construct the controller just once.
This happened in one of the 1.2.x patch releases.
If you are still having a problem please create a new issue with a link to plunker reproducing the issue + description of the actual vs expected behavior.