Premium
Reusable Child Component with @Input/@Output (Two-way Binding)
Expose a value input and a valueChange output to support two-way binding, and keep the child component stateless so the parent owns the source of truth. Concepts: components, inputs outputs, binding, event binding, template syntax.
- Create a reusable child component (standalone) that receives value via @Input.
- Child must emit changes via @Output so the parent can react.
What you’ll build / What this tests
This premium angular coding focuses on Reusable Child Component with @Input/@Output (Two-way Binding). You’ll apply components and inputs-outputs thinking with easy level constraints. The prompt emphasizes Expose a value input and a valueChange output to support two-way binding, and keep the child….
Learning goals
- Translate the prompt into a clear angular API signature and return shape.
- Apply components, inputs-outputs, binding techniques to implement reusable child component with @input/@output (two-way binding).
- Handle easy edge cases without sacrificing readability.
- Reason about time/space complexity and trade-offs in angular.
Key decisions to discuss
- Define the exact input/output contract before coding.
- Prioritize predictable edge-case handling over micro-optimizations.
Evaluation rubric
- Correctness: covers required behaviors and edge cases.
- Clarity: readable structure and predictable control flow.
- Complexity: avoids unnecessary work for large inputs.
- API discipline: no mutation of inputs; returns expected shape.
- Testability: solution is easy to unit test.
Constraints / Requirements
- Create a reusable child component (standalone) that receives value via @Input.
- Child must emit changes via @Output so the parent can react.
- Implement two-way binding pattern: value + valueChange (so parent can use [(value)]).
- Parent component must demonstrate:
- - Property binding: [label]="..." and [value]="..."
- - Event binding: (valueChange)="..." or [(value)]="..."
- UI should include an input + a button inside the child. Child emits updated value when user edits…
- Typing in the child input updates the parent's state (via two-way binding).
- Clicking child button emits an event that the parent logs/increments a counter.
- Parent can also update the value programmatically and child reflects it.
Mini snippet (usage only)
// Example usage
const input = /* reusable child component with @input/@output (two-way binding) input */;
const result = solve(input);
console.log(result);
// Edge case check
const empty = input ?? null;
const fallback = solve(input);
console.log(fallback);
// Expected: describe output shape, not the implementation
// (no solution code in preview)Common pitfalls
- Mutating inputs instead of returning a new value.
- Skipping edge cases like empty input, duplicates, or nulls.
- Overlooking time complexity for large inputs.
Related questions
Upgrade to FrontendAtlas Premium to unlock this challenge. Already upgraded? Sign in to continue.