Script tag executed twice from HTML template of my directive using ng-transclude

I have a directive that transcludes some HTML fetched from CMS into my AngularJS app. When I add a script tag into my directive and add a console message to it, the message is being logged twice.

Here’s my directive:

angular.module('my-directive', [])
  .directive('myDirective', function () {
    return {
      restrict: 'E',
      replace: false,
      transclude: true,
      template: '<section class="my-directive" ng-transclude> 

I am using it like :


Expected result: “ABCD” logged once.

Actual result: “ABCD” logged twice.

Can anyone explain why this happens?

Source: AngularJS