function wizardButtonDirective(action) { angular.module('mgo-angular-wizard') .directive(action, function() { return { restrict: 'A', replace: false, require: '^wizard', link: function($scope, $element, $attrs, wizard) { $element.on("click", function(e) { e.preventDefault(); $scope.$apply(function() { $scope.$eval($attrs[action]); wizard[action.replace("wz", "").toLowerCase()](); }); }); } }; }); } wizardButtonDirective('wzNext'); wizardButtonDirective('wzPrevious'); wizardButtonDirective('wzFinish'); wizardButtonDirective('wzCancel'); wizardButtonDirective('wzReset');