Search code examples
angularangular2-changedetection

Does changedetection run on parent component that only has child selector with property binding in its template


I wondering if Angular changedetection runs on a parent component if the parent component is not rendering the array in its own view, but sending it to the child component through @Input()?

As far as I have understood changedetection is only run items that rendered in the view. In this case as the array is being passed to child element through property binding, does Angular see that array as something that is rendered in the parent components view?

I know that for the child you can set changedetectionstrategy.onpush and then it will only detect changes to the @Input()


Solution

  • No The way that angular change detection system works is whenever an event is triggered or something is changed it only rerenders the templates which contain the changing references due to an event or a method call so in the above the array is rendered in the child component and id the array is changed somehow it will only re-render the child component it wont re-render the parent component.

    for more information https://blog.angular-university.io/how-does-angular-2-change-detection-really-work/