12345678910111213141516171819202122232425262728 |
- 'use strict';
- // signup controller
- app.controller('SignupFormController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
- $scope.user = {};
- $scope.authError = null;
- $scope.signup = function () {
- if ($scope.user.password != $scope.user.password2) {
- $scope.authError = '2次输入的密码不同';
- return;
- }
- $scope.authError = null;
- // Try to create
- $http.post('/manager/user/signup', {username: $scope.user.username, password: $scope.user.password})
- .then(function (response) {
- var data = response.data;
- if (data.result == 1) {
- $scope.authError = data.description;
- } else {
- $state.go('app');
- }
- }, function (x) {
- $scope.authError = '服务器异常';
- });
- };
- }])
- ;
|