login.controller.js 908 B

1234567891011121314151617181920212223242526272829
  1. (function ()
  2. {
  3. 'use strict';
  4. app.controller('Login', ['$scope', 'account.repository', '$location', function ($scope, accountRepository, $location)
  5. {
  6. $scope.user =
  7. {
  8. login: 'admin@gmail.com',
  9. password: 'qQ1!1111'
  10. };
  11. $scope.login = function ()
  12. {
  13. accountRepository.login($scope.user)
  14. .then(function (response) {
  15. $location.path('/');
  16. localStorage.setItem('authToken', response.data.authToken);
  17. //console.log(localStorage.authToken);
  18. }, function (error)
  19. {
  20. alert(error)
  21. }
  22. )
  23. };
  24. }
  25. ]);
  26. }
  27. )();