loginNew(logindata:any){
this.service.loginUser(this.user).subscribe(()=>{
console.warn(logindata);
this.alertify.success("Successfully entered!");
window.setTimeout(function(){location.reload()},2000);});
}
This is my function but I don't know how to write if the entrance is invalid.
CodePudding user response:
What you want to do is to return a success function in case of success, or a failure function in case of failure.,
In that case, You will be able to control the user output for whatever outcomes.
loginNew(logindata:any){
this.service.loginUser(this.user).subscribe(
(success) => {
console.warn(logindata);
this.alertify.success("Successfully entered!");
window.setTimeout(function(){location.reload()},2000);});
},
(failure) => {
alert(failure.message)
}
}