Recall & Review
beginner
What is the purpose of the
@Input decorator in Angular?The
@Input decorator allows a parent component to pass data to its child component. It marks a property in the child component as a target for receiving input values from the parent.Click to reveal answer
beginner
How do you use the
@Input decorator in a child component?You import <code>@Input</code> from <code>@angular/core</code> and add it before a property declaration in the child component class. This property will then receive data from the parent component's template.Click to reveal answer
intermediate
Can the
@Input property name be different from the attribute name used in the parent template?Yes. You can provide an alias inside the
@Input decorator like @Input('aliasName'). The parent uses the alias name in its template, while the child uses the property name internally.Click to reveal answer
beginner
What happens if the parent does not provide a value for an
@Input property?The
@Input property in the child component will be undefined unless it has a default value set in the child component class.Click to reveal answer
intermediate
Why is the
@Input decorator important for component communication?It enables clear, one-way data flow from parent to child components, making the app easier to understand and maintain by separating concerns and avoiding direct manipulation of child internals.
Click to reveal answer
What does the
@Input decorator do in Angular?✗ Incorrect
The
@Input decorator marks a property in the child component to receive data from the parent.How do you import the
@Input decorator?✗ Incorrect
The
@Input decorator is imported from @angular/core.If you want to use a different name for the input property in the parent template, what do you do?
✗ Incorrect
You can provide an alias name inside the
@Input decorator to use a different attribute name in the parent template.What will be the value of an
@Input property if the parent does not bind any value?✗ Incorrect
If the parent does not provide a value, the
@Input property is undefined unless the child sets a default.Which direction does data flow when using
@Input?✗ Incorrect
@Input is used for one-way data flow from parent component to child component.Explain how the
@Input decorator works to pass data from a parent to a child component in Angular.Think about how the parent template uses the child selector with property binding.
You got /4 concepts.
Describe a scenario where you would use an alias with the
@Input decorator and how to implement it.This helps when you want clearer or different naming in the parent template.
You got /4 concepts.