Advertisement
Guest User

Untitled

a guest
May 6th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. 'use strict';
  2.  
  3. class LoginController {
  4. constructor(Auth, $state) {
  5. this.user = {};
  6. this.errors = {};
  7. this.submitted = false;
  8.  
  9. this.Auth = Auth;
  10. this.$state = $state;
  11. }
  12.  
  13. login(form) {
  14. this.submitted = true;
  15.  
  16. if (form.$valid) {
  17. this.Auth.login({
  18. email: this.user.email,
  19. password: this.user.password
  20. })
  21. .then(() => {
  22. // Logged in, redirect to home
  23. this.$state.go('main');
  24. })
  25. .catch(err => {
  26. this.errors.other = err.message;
  27. });
  28. }
  29. }
  30. }
  31.  
  32. angular.module('lolstatsApp')
  33. .controller('LoginController', LoginController);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement