├── .gitignore ├── images ├── nacho-libre.jpg └── nacho-thanks.jpg ├── README.md ├── app.js ├── index.html ├── app.css └── partials └── wizard.html /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea -------------------------------------------------------------------------------- /images/nacho-libre.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simpulton/angularjs-wizard/HEAD/images/nacho-libre.jpg -------------------------------------------------------------------------------- /images/nacho-thanks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/simpulton/angularjs-wizard/HEAD/images/nacho-thanks.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angularjs-wizard 2 | ================ 3 | 4 | An AngularJS wizard using the ng-animate directive. 5 | 6 | ## Resources 7 | The companion tutorial for this code is here http://onehungrymind.com/ng-animate-first-look-with-angularjs-wizard/ 8 | For more information on AngularJS please check out http://angularjs.org/ 9 | Great writeup on ng-animate, http://www.yearofmoo.com/2013/04/animation-in-angularjs.html 10 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | angular.module('App', ['ngAnimate', 'ui.bootstrap']) 2 | .controller('AppCtrl', function ($modal) { 3 | var app = this; 4 | 5 | app.closeAlert = function () { 6 | app.reason = null; 7 | }; 8 | 9 | app.open = function () { 10 | var modalInstance = $modal.open({ 11 | templateUrl: 'partials/wizard.html', 12 | controller: 'ModalCtrl', 13 | controllerAs: 'modal' 14 | }); 15 | 16 | modalInstance.result 17 | .then(function (data) { 18 | app.closeAlert(); 19 | app.summary = data; 20 | }, function (reason) { 21 | app.reason = reason; 22 | }); 23 | }; 24 | }) 25 | .controller('ModalCtrl', function ($modalInstance) { 26 | var modal = this; 27 | 28 | modal.steps = ['one', 'two', 'three']; 29 | modal.step = 0; 30 | modal.wizard = {tacos: 2}; 31 | 32 | modal.isFirstStep = function () { 33 | return modal.step === 0; 34 | }; 35 | 36 | modal.isLastStep = function () { 37 | return modal.step === (modal.steps.length - 1); 38 | }; 39 | 40 | modal.isCurrentStep = function (step) { 41 | return modal.step === step; 42 | }; 43 | 44 | modal.setCurrentStep = function (step) { 45 | modal.step = step; 46 | }; 47 | 48 | modal.getCurrentStep = function () { 49 | return modal.steps[modal.step]; 50 | }; 51 | 52 | modal.getNextLabel = function () { 53 | return (modal.isLastStep()) ? 'Submit' : 'Next'; 54 | }; 55 | 56 | modal.handlePrevious = function () { 57 | modal.step -= (modal.isFirstStep()) ? 0 : 1; 58 | }; 59 | 60 | modal.handleNext = function () { 61 | if (modal.isLastStep()) { 62 | $modalInstance.close(modal.wizard); 63 | } else { 64 | modal.step += 1; 65 | } 66 | }; 67 | 68 | modal.dismiss = function(reason) { 69 | $modalInstance.dismiss(reason); 70 | }; 71 | }); 72 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
17 | Coming: {{app.summary.coming}}
29 | 30 |Tacos: {{app.summary.tacos}}
31 | 32 |Toppings:
33 | 34 |