Reputation: 496
I'm working on a CRM and I have a select box in the header which allows the user to change the current user, In addition, the main content is inside the router-outlet.
When the user select another user I want to refresh the page but only the router-outlet so the info will be for the new user
I saw that other CRMs just redirect the user to the dashboard / index page, but I want to keep the user on the same page.
Upvotes: 0
Views: 1334
Reputation: 11287
You should have a function in a service
import {Subject} from 'rxjs/Subject';
onUserChange= new Subject<void>();
userChange(): void {
this.http.post('')
.map()
.subscribe((data: UserChangeResponse) => {
this.onUserChange.next();
})
}
And In component you can use it in ngOnInit
serviceReference.onUserChange.subscribe(() => {
// use can call get users method or anything
});
Upvotes: 3