Skip to content

Instantly share code, notes, and snippets.

@marianoqueirel
Created October 13, 2016 14:27
Show Gist options
  • Save marianoqueirel/eba9c8fafcab24821eaeddacfa94b2ce to your computer and use it in GitHub Desktop.
Save marianoqueirel/eba9c8fafcab24821eaeddacfa94b2ce to your computer and use it in GitHub Desktop.
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;
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment