如何刷新角度分量

hes*_*wky 1 javascript typescript angular

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

所以我需要刷新抽屉组件以获得基于 dom 方向的正确样式rtlltr

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

Moh*_*lam 5

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

fn() {
    this.ngOnInit();
}
Run Code Online (Sandbox Code Playgroud)

或者试试这个

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