'use strict'; /* Controllers */ // signin controller app.controller('SigninFormController', ['$scope', '$http', '$state', 'md5', function ($scope, $http, $state, md5) { var username = getQueryString('username'); $scope.user = {username: username}; $scope.authError = null; $scope.login = function () { $scope.authError = null; // Try to login $http.post('/manager/login', {username: $scope.user.username, password: md5.createHash($scope.user.password)}) .then(function (response) { var data = response.data; if (data.result == 1) { // $state.go('app.ad.manage'); window.location.href = "./index.html?t=" + new Date().getTime() + "";//todo 防止切换用户没有刷新当前用户数据 或许有更好的方案 } else { $scope.authError = data.description; } }, function (x) { $scope.authError = '服务器异常'; }); }; }]) ;