How to refresh a route's resolved data

前端 未结 4 1368
执笔经年
执笔经年 2021-01-04 01:09

Consider the following route configuration:

const routes: Routes = [
  {
    path: \'\',
    component: AppComponent,
    resolve: {
      app: AppResolver
          


        
4条回答
  •  温柔的废话
    2021-01-04 01:34

    You can try something like this:

    constructor(private activatedRoute: ActivatedRoute) {
      this.activatedRoute.parent.data.subscribe(data => {
        this.profile = data.profile;
      });
    }
    
    updateProfile(newProfile) {
      (this.activatedRoute.parent.data as BehaviorSubject).next({profile: newProfile});
    }
    

提交回复
热议问题