0

I want to append <tr><button></button></tr> to the <thead>in the below html.

  <table>
    <thead>
    <tr>
    Header 1
    </tr>
    </thead>

  </table>

Is it possible to achieve the idea above using angular directives?

1 Answer 1

1

in your linking function of your costum directive you can use

angular.element(document).find("thead").append("<tr><button></button></tr>")

your directive could look like this:

angular.module('app', [])
.directive('myDirective', ['$document', function($document) {
  return {
    link: function(scope, element, attr) {
      angular.element(document).find("thead").append("<tr><button></button></tr>")
    }
  };
}]);

carefull i havent tested this code but this is the way to manipulate DOM in custom directives ,i will make a plunker when i can

Sign up to request clarification or add additional context in comments.

1 Comment

you need to post your full code to help you further or even better make a plunker with it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.