title: AngularJS check if function exists in directive
body: <p>I have a directive with the following scope:</p>
  
  <pre class="lang-js prettyprint-override"><code>scope: {
    copyObject: '&amp;',
    deleteObject: '&amp;'
  }
  </code></pre>
  
  <p>Now, I have a corresponding button in my template which looks like this:</p>
  
  <pre class="lang-html prettyprint-override"><code> &lt;button ng-click="copyObject()"&gt;Copy&lt;/button&gt;
  </code></pre>
  
  <p>However, I would like to hide the button if there's no function applied to <code>copy-object</code>, for example:</p>
  
  <pre><code>&lt;!-- Should show the copy button --&gt;
  &lt;my-directive copy-object="copyObject()"&gt;&lt;/my-directive&gt;
  
  &lt;!-- Should not show the copy button --&gt;
  &lt;my-directive&gt;&lt;/my-directive&gt;
  </code></pre>
  
  <p>So I applied the following to my template:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;button ng-click="copyObject()" ng-if="copyObject"&gt;Copy&lt;/button&gt;
  </code></pre>
  
  <p>But this does not seem to work, if I check the directives real isolated scope, I notice that, even when the attribute is not entered, the function still exists, so the button is always visible.</p>
  
  <p>Is it possible to detect if a function is bound to the <code>copyObject()</code> or not? And is it a good practice to do so? I'm not sure if the directive should be aware of the bound function or is this some kind of scope access violation?</p>
  
  <p>An example: <a href="http://jsfiddle.net/azchpo5q/" rel="nofollow">http://jsfiddle.net/azchpo5q/</a> (the second button should not be visible because there is no action bound to it).</p>