Angular · Middle · Question 67 of 75

How do you create a component dynamically and set its inputs?

const ref = this.vcr.createComponent(Toast);
ref.setInput('message', 'Saved');

Explanation

setInput works with signal inputs and marks OnPush components for check. NgComponentOutlet covers simple template cases.

Further reading

Problem with a question

Angular · Middle · question 67

Test yourself

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

Take this quiz