Skip to content

Instantly share code, notes, and snippets.

@avatsaev
Last active February 10, 2017 09:57
Show Gist options
  • Save avatsaev/34b197e3138b1f3c007082c21d23df83 to your computer and use it in GitHub Desktop.
Save avatsaev/34b197e3138b1f3c007082c21d23df83 to your computer and use it in GitHub Desktop.
import {Component, OnInit, Output, EventEmitter} from '@angular/core';
import {Angular2TokenService} from "angular2-token";
@Component({
selector: 'app-login-form',
templateUrl: './login-form.component.html',
styleUrls: ['./login-form.component.sass']
})
export class LoginFormComponent implements OnInit {
signInUser = {
email: '',
password: ''
};
@Output() onFormResult = new EventEmitter<any>();
constructor(private tokenAuthSerivce:Angular2TokenService) { }
ngOnInit() {}
onSignInSubmit(){
this.tokenAuthSerivce.signIn(this.signInUser).subscribe(
res => {
if(res.status == 200){
this.onFormResult.emit({signedIn: true, res});
}
},
err => {
console.log('err:', err);
this.onFormResult.emit({signedIn: false, err});
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment