signup.js 943 B

12345678910111213141516171819202122232425262728
  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. if ($scope.user.password != $scope.user.password2) {
  8. $scope.authError = '2次输入的密码不同';
  9. return;
  10. }
  11. $scope.authError = null;
  12. // Try to create
  13. $http.post('/manager/user/signup', {username: $scope.user.username, password: $scope.user.password})
  14. .then(function (response) {
  15. var data = response.data;
  16. if (data.result == 1) {
  17. $scope.authError = data.description;
  18. } else {
  19. $state.go('app');
  20. }
  21. }, function (x) {
  22. $scope.authError = '服务器异常';
  23. });
  24. };
  25. }])
  26. ;