Reputation: 103
I am using the ngx-alert service to display an error message if the credentials don' t correspond to a user account in my db.
This is what i did:
if (this.check.data.length == 0) {
this.alert.danger('User doesn\'\t exist');
this.userForm.reset()
}
else {
this.alert.success('You are going to be redirected');
sessionStorage.setItem('user',this.check.data[0].username);
setTimeout(this.router.navigate(['/home',{data: 'ok'}] ), 3000)
}
When the user exists, the message is displayed correctly but after ther redirection with router.navigate is not working, i get the following error:
i don' t understand this error, i don't see when i am calling the Object()
Thanks you for your help
Upvotes: 0
Views: 686
Reputation: 1449
Looks Like this statement is not correct
setTimeout(this.router.navigate(['/home',{data: 'ok'}] ), 3000)
Use it Like:
setTimeout(()=> {this.router.navigate(['/home',{data: 'ok'}] )}, 3000)
Upvotes: 1