我想通过角度函数刷新页面

问题描述 投票:0回答:1

我是角度新手,我试图完成这项工作,这里的“confirmDoctor”函数正在通过api进行一些更改,现在我想要自动刷新某些角度变化检测页面的方法,以便它会调用getInfo 方法再次给我更新的值。 现在我必须手动刷新浏览器才能看到更改。

 async confirmDoctor(selectedDoctor:string,pid:string){
    console.log(selectedDoctor);
    await this.assign.AssignDoctor(selectedDoctor,pid).subscribe(
      (response)=>{
        console.log(response);
        })  
  }

  ngOnInit(){

    this.getinfo.getInfo('patient').subscribe((response)=>
    {
      this.data = response;
      console.log(this.data);
    })
    this.doc$ = this.getinfo.getInfo('doctor');
  }
}

由于我是角度新手,我真的不知道我需要什么,我尝试了一些变化检测方法,但我做不到, 有效的方法是在函数内部再次调用 ngOnInit() ,但我认为这不是正确的解决方案。

angular angularjs angular-ui-router angular-lifecycle-hooks
1个回答
0
投票

您想要获取“getInfo('Patent')”方法的更新值,为此,您可以创建另一个函数并在 ngOnInit 中使用该函数,然后在响应“AssignDoctor”方法中获取更新值.

© www.soinside.com 2019 - 2024. All rights reserved.