Skip to content

Instantly share code, notes, and snippets.

@owrrpon
Created June 5, 2021 15:50
Show Gist options
  • Save owrrpon/87e14483fd2ad6c32da976f829f98453 to your computer and use it in GitHub Desktop.
Save owrrpon/87e14483fd2ad6c32da976f829f98453 to your computer and use it in GitHub Desktop.
calling the service method for the API
export class LoginComponent implements OnInit, OnDestroy {
login_form!: FormGroup;
// Subscription
private initiate_login_sub!: Subscription;
constructor(
private global_utilities: AppUtilityService
) { }
ngOnInit(): void {
this.login_form = new FormGroup({
username: new FormControl('', [Validators.required]),
password: new FormControl('', [Validators.required])
});
}
initiateLogin(){
this.initiate_login_sub = this.global_utilities.login(this.login_form.value).subscribe(
(data)=>{
this.global_utilities.navigateToURL('/secure');
},
(error)=>{
//TODO
}
);
}
ngOnDestroy(): void{
this.global_utilities.unsubscribeAll([
this.initiate_login_sub
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment