0

This is just a conceptual question. I am trying to learn more about how Angular lifecycle hooks work.

My question is, if I have a nested component structure like below:

<parent-component>
    <first-child>
        <first-grandchild>
        </first-grandchild>
    </first-child>
    <second-child>
    </second-child>
</parent-component>

If eg the onChanges lifecycle hook is activated for one component, will it be activated for all child/sibling components?

If the answer to that is no, is there a non-hacky way to implement something to replicate that behaviour, or is it not supported?

2
  • May be xml-js works in the server side and not in the browser. You can check this answer for more info: stackoverflow.com/questions/45685100/… Commented Sep 12, 2019 at 10:09
  • onChanges will get called immediately data-bound properties if at least one has changed. It will not be activicate/called for all child components. Commented Sep 12, 2019 at 10:26

1 Answer 1

0

Change detection flows from parent to child components. As for ngOnChanges lifecycle, it is called when a bounded property of a component(decorated with @Input() decorator) changes in the parent component.

This article explains it quite well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.