title: What is angularjs $compile double parenthesis
body: <p>I 'm a bit worried If I am asking a noob question or if it is a javascript feature that I haven't been able to locate despite plenty of googling</p>
  
  <p>I am adding a simple directive programmatically using $compile and all is working fine.</p>
  
  <p>My question is this line </p>
  
  <pre><code>var el = $compile(newElement)($scope);
  </code></pre>
  
  <p>How do the double parenthesis work/ what do they do? Complete code below for reference but its just the parenthesis which I am not sure about.</p>
  
  <pre><code>var myApp = angular.module('myApp', []);
  
  myApp.directive('myDirective', function() {
     return {
          template: 'Hello',
          restrict: 'E'
      }
  });
  
  myApp.controller('mainController', [
      '$scope', '$compile', function($scope, $compile) {
  
          $scope.addDirective = function() {
              var newElement = angular.element(document.createElement('my-directive'));
              var el = $compile(newElement)($scope);
              angular.element(document.body).append(el);
          };
      }
  ]);
  </code></pre>