Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print angular element tag-name inside linking function

Tags:

angularjs

Jsfiddle is here.

Inside my directive's linking function, i am trying to print the directive element's tag name as,

myApp.directive('myDirective', function () {
    return {
      link: function (scope, element, attrs) {
          element.append('<hr>you know, my tag name is ' + element.tagName)

         }
    }
})

It prints undefined whereas i expect the directive's tag name my-directive to be printed.


1 Answers

You should use this element[0].tagName

like image 104
rkalita Avatar answered Mar 06 '26 13:03

rkalita



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!