Skip to content

Instantly share code, notes, and snippets.

@clouddueling
Created October 12, 2013 20:34
Show Gist options
  • Select an option

  • Save clouddueling/6954651 to your computer and use it in GitHub Desktop.

Select an option

Save clouddueling/6954651 to your computer and use it in GitHub Desktop.
AngualarJS Wizard service based on https://github.com/simpulton/angularjs-wizard
services.factory('Wizard', [function(){
var wizardService = {},
steps = [],
step = 0,
finishLabel = "Finish";
wizardService.isFirstStep = function() {
return step === 0;
};
wizardService.isLastStep = function() {
return step === (steps.length - 1);
};
wizardService.isCurrentStep = function(iStep) {
return step === iStep;
};
wizardService.setCurrentStep = function(iStep) {
step = iStep;
};
wizardService.setFinishLabel = function (iFinishLabel) {
finishLabel = iFinishLabel;
}
wizardService.setSteps = function(iSteps) {
steps = iSteps;
};
wizardService.getCurrentStep = function() {
return steps[step];
};
wizardService.getNextLabel = function() {
return (this.isLastStep()) ? finishLabel : 'Next';
};
wizardService.handlePrevious = function() {
step -= (this.isFirstStep()) ? 0 : 1;
};
wizardService.handleNext = function(dismiss) {
if(this.isLastStep()) {
dismiss();
} else {
step += 1;
}
};
wizardService.reset = function() {
steps = [];
step = 0;
finishLabel = "Finish";
};
return wizardService;
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment