Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Duplicate attributes when using directive compile with transclude #2576

MathewBerg opened this Issue · 5 comments

4 participants


JsFiddle of the issue:

When using the angularJs transclude within a directives compile, it will duplicate any attribute properties. I.e. if the class is set to class="myClass" the result will be class="myClass myClass". Similarly for ng-click="myFunction()" will become ng-click="myFunction() myFunction()". The fiddle demonstrates this, and unfortunately it crashes. It's a stripped down version of what I'm trying to implement


I managed to track down part of it... not really sure how the inner works are but if I change the code for mergeTempalteAttributes to reapply the old attributes to this:

  forEach(dst, function(value, key) {
    if (key.charAt(0) != '$') {
      var splitType = (key === 'style' ? ';' : ' ');        
      var alreadyAddedCheck = (value && value.indexOf(src[key] + splitType) === -1 && value.indexOf(splitType + src[key]) === -1 && value != src[key]);
        if (src[key]) {
          value += splitType + src[key];
        dst.$set(key, value, true, srcAttr[key]);

The duplicate goes away. But the event still fires twice on ngClick.


More searching seems to point towards the directive compiling twice.

@btford btford closed this

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.



I'm experiencing a similar regression in 1.2.0 which I described at!topic/angular/IhV_FApq-A4 I am not sure if this is related but it smells like it could be.


I'm writing a Directive , its template has a attribute "ng-click", and the setting is {relpace: true, scope: true} .

If the Directive name is "angularTestDirective", When using it in the some template:

Why the "testFun" function and the Directive ng-click all has been triggered twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.