Advertisement
Guest User

Untitled

a guest
Oct 13th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. 'use strict';
  2.  
  3. import angular from 'angular';
  4. import uiRouter from 'angular-ui-router';
  5. import routes from './login.routes';
  6.  
  7. export class LoginComponent {
  8. /*@ngInject*/
  9.  
  10. constructor(Auth, $state) {
  11. this.Auth = Auth;
  12. this.$state = $state;
  13. this.errors = {login: ''};
  14. }
  15.  
  16. login(form) {
  17. this.submitted = true;
  18.  
  19. const user = {
  20. email: this.user.email,
  21. password: this.user.password
  22. };
  23.  
  24. if (form.$valid) {
  25. this.Auth.login(user)
  26. .then(
  27. (data) => {
  28. this.errors.login = data;
  29. // Logged in, redirect to home
  30. //this.$state.go('main');
  31. },
  32. (err) => {
  33. this.errors.login = err;
  34. }
  35. );
  36. }
  37. }
  38.  
  39. close() {
  40. this.submitted = false;
  41. this.errors = {};
  42. }
  43. }
  44.  
  45. export default angular.module('sisaApp.login', [uiRouter])
  46. .config(routes)
  47. .component('login', {
  48. template: require('./login.html'),
  49. controller: LoginComponent
  50. })
  51. .name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement