'use strict';

app.directive('submitAndDisable', function() {
  return {
    scope: {
      submitAndDisable: '&'
    },
    link: function(scope, elem, attrs) {
      console.log(elem);
      elem.bind('submit', function() {
        var btn = angular.element('button[type=submit]');
        btn.prop('disabled',true);
        scope.submitAndDisable().finally(function() {
          btn.prop('disabled',false);
        });
      });
    }
  };
});