/*
* app.js
* An example app that uses the angularjs step.
*/
var app = angular.module('testStep', ['angular.step']);
app.run(function ($rootScope) {
$rootScope.testSubmit = function () {
alert("You clicked submit.");
};
});
/**
* @ngdoc overview
* @name angular-step
*
* @description
* An AngularJS way of building clean "wizard" like applications.
*/
angular.module('angular.step', [])
.controller('StepSetController', ['$scope', function ($scope) {
var ctrl = this,
index = -1, // points to the current step in the steps array
steps = ctrl.steps = $scope.steps = [];
$scope.nextEnabled = true;
$scope.previousEnabled = false;
$scope.submitEnabled = false;
/*
* Moves to the next step
*/
$scope.next = function () {
if (steps.length === 0) {
console.debug('No steps provided.');
return;
}
// If we're at the last step, then stay there.
if (index == steps.length - 1) {
console.debug('At last step.');
return;
}
steps[index++].isDisplayed = false;
steps[index].isDisplayed = true;
ctrl.setButtons();
}; // $scope.next
/*
* Moves to the previous step
*/
$scope.previous = function () {
if (steps.length === 0) {
console.debug('No steps provided.');
return;
}
if (index === 0) {
console.debug('At first step');
return;
}
steps[index--].isDisplayed = false;
steps[index].isDisplayed = true;
ctrl.setButtons();
}; // $scope.previous
$scope.submit = function () {
$scope.submitAction();
};
/*
* Adds a step to the end of the step list and
* sets the index to 0 if it's the first step added.
*/
ctrl.addStep = function (obj) {
ctrl.steps.push(obj);
if (index == -1) {
index = 0;
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.