title: How to check if a method argument of a directive is specified in AngularJS?
body: <p>I've created a custom directive which contains a button. This button calls a method from parent scope specified by 'callback' attribute.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app="app"&gt;
  &lt;head&gt;
      &lt;title&gt;Simple directive&lt;/title&gt;
  
      &lt;script src="js/lib/angular/angular.js"&gt;&lt;/script&gt;
  
      &lt;script type="text/javascript"&gt;
          var app = angular.module('app', []);
  
          app.controller('TestController', function($scope) {
  
              $scope.doSomething = function(param) {
                  alert('Something called with: ' + param);
              }
          })
  
          app.directive('myDirective', function() {
              var ret = {
                  restrict: 'E',
                  scope: {
                      user: '@',
                      callback: '&amp;'       // bound a function from the scope
                  },
                  template: '&lt;div&gt;Hello {{user}}&lt;button ng-show="hasCallback()" ng-click="callback({userData: user})"&gt;Callback&lt;/button&gt;',
                  controller: function($scope) {
                      $scope.hasCallback2 = function() {
                          var t = typeof $scope.callback;
                          return t == 'function';
                      }
  
                      $scope.hasCallback = function() {
                          return angular.isDefined($scope.callback);
                      }
                  }
              };
              return ret;
          });
  
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body ng-controller="TestController"&gt;
  
  &lt;my-directive user="cat" callback="doSomething(userData)"&gt;&lt;/my-directive&gt;
  &lt;my-directive user="dog" callback="doSomething(userData)"&gt;&lt;/my-directive&gt;
  &lt;my-directive user="pig"&gt;&lt;/my-directive&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>My question is:</p>
  
  <p>How can I control visibility of button inside template? I'd like to hide it if callback attribute not specified in custom tag (see 3rd my-directive tag).
  When I check typeof of callback, I always get 'function' and angular.isDefined(...) also returns true.</p>