Created
June 5, 2021 15:50
-
-
Save owrrpon/87e14483fd2ad6c32da976f829f98453 to your computer and use it in GitHub Desktop.
calling the service method for the API
This file contains hidden or 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
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