Angular 2 life cycle hook after all children are initialized?

后端 未结 7 1556
走了就别回头了
走了就别回头了 2020-12-15 15:10

I am looking for a concept to implement the following case:

I have a parent search component that has some components as view children / content children for displa

7条回答
  •  余生分开走
    2020-12-15 15:41

    I ended up using the ngAfterViewInit() hook in the following way:

    ngAfterViewInit(){
      //stuff that doesn't do view changes
      setTimeout(_=> this.methodThatKicksOffAnotherRoundOfChanges());
    }
    

    This should be safe to use compared to other invocations of setTimeout where an actual time is set, since it should start instantly (and just affect the threading/context behaviour)

提交回复
热议问题