I am a beginner of the Angular.io.
I created 2 component: "HeaderComponent" act as a page header & "RestaurantComponent" act as a page body.
There is an "Add Restaurant" button in the HeaderComponent, when clicked on it, it will display a form in a lightbox(modal).
The Add Restaurant form will call API when click on the submit button:
this.restaurantService.addRestaurantDetails(newRestaurant)
.subscribe(restaurant => {
location.reload(); //this will caused it reload entire page
});
What i need is when i click "Submit" in my form, then refresh the current component(RestaurantComponent in this case). If i am at another component like "DashboardComponent", i would like to refresh the Dashboard component as well.
Additionally, i would like know how to redirect to another component in the callback function as well. E.g. i am at the RestaurantComponent, when i click on the form submit button, i would like to navigate to DashboardComponent.
Thank you in advance!