首页 > 解决方案 > 如何刷新角度组件

问题描述

我正在使用ionic 4两种语言构建一个移动应用程序,ar并且en菜单抽屉是一个预构建的组件。

所以我需要刷新抽屉组件以根据 dom 方向rtlltr

我现在正在做的只是location.reload重新加载整个应用程序,但我认为这不是一个好方法

标签: javascriptangulartypescript

解决方案


最简单的方法是调用 ngOnInit 类似

fn() {
    this.ngOnInit();
}

或者试试这个

this.router.navigateByUrl('/RefreshComponent', { skipLocationChange: true })
  .then(() => {
      this.router.navigate(['Your actualComponent']);
}); 

推荐阅读