In general, you should not call $compile twice on the same piece of dom. If 
you are adding directives in the children of your directive you are fine 
just adding the dom from the compile (since the children have not been 
compiled yet:

directive('validateForm', function ($compile) {
    return {
        restrict: 'A',
        compile: function (element, attrs) {
           var form = element.find('form');
           form.append('<label ng-show="formName.total.$error.noteven" 
for="total">The total field should not be even.</label>');
        }
    };
});

If you need to add additional directives to the same element of your 
directive, then you should set terminal: true and give it a high priority. 
This will stop compilation at your directive, which can then modify the dom 
and call compile again with a maximum priority (so that your directive does 
not get called again).

 

-- 
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/groups/opt_out.

Reply via email to