Angular2 update router-out
I am working on CRM and I have a select box in the header that allows the user to change the current user. Also, the main content is inside the router.
When the user selects another user, I want to refresh the page, but only the router-out, so that the information is for the new user.
I've seen other CRMs just redirect the user to the panel / index page, but I want the user to be on the same page.
0
source to share
1 answer
You must have a function in the 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
});
+3
source to share