Reload child component when variables on parent component changes. Angular2

后端 未结 5 682
粉色の甜心
粉色の甜心 2020-12-24 01:30

I have a MasterComponent which loads header, footer, sidebar etc. On the header there is a dropdown whose options are set once the user is logged in. I want the header to be

5条回答
  •  孤独总比滥情好
    2020-12-24 01:56

    In case, when we have no control over child component, like a 3rd party library component.

    We can use *ngIf and setTimeout to reset the child component from parent without making any change in child component.

    .template:

    .ts:

    show:boolean = true
    
    resetChildForm(){
       this.show = false;
    
       setTimeout(() => {
          this.show = true
        }, 100);
    }
    

提交回复
热议问题