title: Disable text selection with Angular directive
body: <p>I am learning JavaScript and AngularJS.</p>
  
  <p>I want to disable text selection with Angular Directive.</p>
  
  <p>I have a JavaScript code for that function:</p>
  
  <pre><code>function clearSelection() {
      if(document.selection &amp;&amp; document.selection.empty) {
          document.selection.empty();
      }
      else if(window.getSelection) {
          var sel = window.getSelection();
          sel.removeAllRanges();
      }
  };
  </code></pre>
  
  <p>And I am working on the directive, but don't know how to add that function to the directive.</p>
  
  <p>Directive:</p>
  
  <pre><code>...
  .directive('disableTextSelection', function() {
      return {
          link: function($scope, $element, $attrs) {
              // Something here..
          }
      }
  }
  ...
  </code></pre>
  
  <p>And I want to do this in HTML like:</p>
  
  <pre><code>&lt;table disable-text-selection&gt;
      ...
  &lt;/table&gt;
  </code></pre>