Created
May 10, 2013 19:19
-
-
Save johnsinco/5556734 to your computer and use it in GitHub Desktop.
simple angularjs demo of a wizard flow (doesn't work)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('register', ['ngResource', 'rails']). | |
config(function($routeProvider) { | |
$routeProvider. | |
when('/', {controller:RegisterCtrl, templateUrl:'/partials/register.html'}). | |
when('/#profile', {controller:RegisterCtrl, templateUrl:'/partials/profile.html'}). | |
when('/#preferences', {controller:RegisterCtrl, templateUrl:'/partials/preferences.html'}). | |
otherwise({redirectTo:'/'}); | |
}); | |
angular.module('register').factory('User', ['railsResourceFactory', function (railsResourceFactory) { | |
return railsResourceFactory({url: '/users', name: 'user'}); | |
}]); | |
var RegisterCtrl = function($scope, $location, User) { | |
$scope.user = new User(); | |
$scope.createAccount = function() { | |
$scope.user.create(); | |
$scope.step = "profile" | |
$location.path('/#profile'); | |
} | |
$scope.completeProfile = function() { | |
$scope.user = User.get($scope.user.id).then(function(user) { | |
user.phone = $scope.user.phone | |
user.street = $scope.user.street | |
user.update(); | |
}); | |
$scope.step = "preferences" | |
$location.path('/#preferences'); | |
} | |
$scope.confirm = function() { | |
$scope.user = User.save($scope.user) | |
$scope.step = "thanks" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment