signup.js 658 B

12345678910111213141516171819202122
  1. 'use strict';
  2. // signup controller
  3. app.controller('SignupFormController', ['$scope', '$http', '$state', function($scope, $http, $state) {
  4. $scope.user = {};
  5. $scope.authError = null;
  6. $scope.signup = function() {
  7. $scope.authError = null;
  8. // Try to create
  9. $http.post('api/signup', {name: $scope.user.name, email: $scope.user.email, password: $scope.user.password})
  10. .then(function(response) {
  11. if ( !response.data.user ) {
  12. $scope.authError = response;
  13. }else{
  14. $state.go('app.dashboard-v1');
  15. }
  16. }, function(x) {
  17. $scope.authError = 'Server Error';
  18. });
  19. };
  20. }])
  21. ;