angular 路由本页时不跳转问题
利用ActivationEnd事件来初始化参数来达到页面跳转(刷新);
步骤:
1.导入ActivationEnd,如下:
import { ActivationEnd} from ‘@angular/router’;
2.在构造器(constructor)中加入对ActivationEnd事件的监听如下:
router.events.subscribe(event => {
//解决路由到本页时不刷新数据的问题
if(event instanceof ActivationEnd) {
this.appGlobalService.formComponent = this;
this.initParams();
this.initData();
}
})