title: How to call a function of AngularJS directive when click anywhere on page?
body: <p>I want to call close() function on click anywhere in page,but didn't work. I have written like:</p>
  
  <pre><code>var liveSearch = function () {
  return {
      restrict: "A",
      scope: {
          myData: '=',
          ngModel: '='
      },
      templateUrl: "/js/app/common/template/livesearch.html",
      link: function ($scope, element, attrs) {
  
          var close = function() {
              $scope.status = "close";
          };
  
          $scope.open = function () {
              $scope.status = "open";
          };
  
          $(document).on('click',function(){
              close();
          });
      }
  };
  app.directive("liveSearch", liveSearch);
  </code></pre>
  
  <p>Please help to solve this problem.</p>
  
  <p><strong>Edited</strong></p>
  
  <pre><code>&lt;div live-search my-data="data" ng-model="typeId" &gt;&lt;/div&gt;
  </code></pre>