Angular2刷新路由器电源插座 [英] Angular2 refresh router-outlet
本文介绍了Angular2刷新路由器电源插座的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发CRM,并且标题中有一个选择框,允许用户更改当前用户, 此外,主要内容位于路由器出口内.
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
我看到其他CRM只是将用户重定向到仪表板/索引页面, 但我想让用户保持在同一页面上.
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.
推荐答案
您应该在服务中具有功能
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();
})
}
在In组件中,您可以在ngOnInit中使用它
And In component you can use it in ngOnInit
serviceReference.onUserChange.subscribe(() => {
// use can call get users method or anything
});
这篇关于Angular2刷新路由器电源插座的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文