I have wrote a directive called lobInclude, I want the same that ngInclude but with no scope:
.directive("lobInclude", ["$templateRequest", "$compile", function($templateRequest, $compile) {
return {
restrict: "A",
scope: false,
compile: function() {
return {
pre: function(scope, elem, attrs) {
var toObserve = "lobInclude";
attrs.$observe(toObserve, function(value) {
value = scope.$eval(value);
$templateRequest(value, true).then(function(response) {
if (angular.isDefined(attrs.replace))
elem.replaceWith($compile(angular.element(response))(scope));
else
elem.append($compile(angular.element(response))(scope));
});
});
},
post: function() { }
};
}
}
}]);
All seems ok but ng-Messages not work correctly when use my directive, you can see here an example: http://codepen.io/jros/pen/jPxmxj?editors=101
In the code pen I have a form with an input and my directive that include a script ng-template that contains other input.
The ng-messages in the first input work fine but not in my include.
Any ideas please?