Last active
October 13, 2016 14:30
-
-
Save marianoqueirel/8242dbf4145a8310bf822c94cc3291dd to your computer and use it in GitHub Desktop.
Help / Promises
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
import angular from 'angular'; | |
import uiRouter from 'angular-ui-router'; | |
import routes from './login.routes'; | |
export class LoginComponent { | |
/*@ngInject*/ | |
constructor(Auth, $state) { | |
this.Auth = Auth; | |
this.$state = $state; | |
this.errors = {login: ''}; | |
} | |
login(form) { | |
this.submitted = true; | |
const user = { | |
email: this.user.email, | |
password: this.user.password | |
}; | |
if (form.$valid) { | |
this.Auth.login(user) | |
.then( | |
(data) => { | |
this.errors.login = data; | |
// Logged in, redirect to home | |
//this.$state.go('main'); | |
}, | |
(err) => { | |
this.errors.login = err; | |
} | |
); | |
} | |
} | |
close() { | |
this.submitted = false; | |
this.errors = {}; | |
} | |
} | |
export default angular.module('sisaApp.login', [uiRouter]) | |
.config(routes) | |
.component('login', { | |
template: require('./login.html'), | |
controller: LoginComponent | |
}) | |
.name; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment