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?

Yes, I know that it may works fine with ng-include but I have 2 reasons for 
do it:
1) I need to include template without create child scope, the real example 
is more complex and need access to the content of template from outside and 
viceversa.
2) I would like learn about directives and I would like why it not works

Any link to documentation or related articles are wellcome.

Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to