Bird
0
0

Given this child component:

medium📝 component behavior Q4 of 15
Angular - Component Interaction
Given this child component:
@Component({ selector: 'child-comp', template: '{{name}}' }) export class ChildComponent { @Input() name!: string; }

And the parent template:
<child-comp [name]="parentName"></child-comp>

If parentName is set to 'Angular', what will the child component display?
A{{name}}
BAngular
CparentName
Dundefined
Step-by-Step Solution
Solution:
  1. Step 1: Data binding

    The parent binds its parentName property to the child's name input.
  2. Step 2: Value passed

    The value 'Angular' is passed to the child's name property.
  3. Step 3: Template rendering

    The child template displays the value of name, which is 'Angular'.
  4. Final Answer:

    Angular -> Option B
  5. Quick Check:

    Input property reflects parent's bound value [OK]
Quick Trick: Child displays parent's bound input value [OK]
Common Mistakes:
  • Expecting the literal string '{{name}}' to display
  • Confusing property name with variable name
  • Assuming undefined if not initialized

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes