Angular · Senior · Question 18 of 75

A recursive tree node component needs its parent node. Which injection option fits?

export class TreeNode {
  parent = inject(TreeNode, { skipSelf: true, optional: true });
}

Explanation

Without skipSelf, the node would find itself. self limits lookup to the current element injector; host stops at the host component's boundary.

Further reading

Problem with a question

Angular · Senior · question 18

Test yourself

Take the Angular · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz