I have a page called Update Profile. When Submit button is pressed, currently it is reloading the page only. I need that it could redirect to dashboard page.
.ts code
this.api.updateProfile(myFormData).subscribe((resp: any) => {
if (resp.status === false) {
this.ts.error(resp.msg);
return false;
} else {
window.location.reload();
this.ts.success(resp.msg);
return true
}
}
.html code
<div class="form-group form-button mb-1">
<div class="form-group form-button mb-1">
<button type="submit" class="btn btn-primary btn-lg px-5" control-id="ControlID-8">
<span class="text-white">Update</span>
</button>
</div>
</div>
)
>Solution :
Pretty simple
this.api.updateProfile(myFormData).subscribe((resp: any) => {
if (resp.status === false) {
this.ts.error(resp.msg);
return false;
} else {
this.router.navigate(['/your-page name']).then(() => {
window.location.reload();
});
this.ts.success(resp.msg);
return true
}
})
return false;
}