Question presented to candidate:
"Show me how model() works. If a child declares rating = model(0), what does the parent bind, what actually gets emitted and when, and what goes wrong if the parent only binds one way?"
What a strong answer should cover:
model()declares an inputratingand an outputratingChangefrom one field;[(rating)]="sig"binds both.- The output fires only when the child sets a different value; writes coming from the parent do not echo back.
[(rating)]takes the signal itself (sig, notsig()); a plain field also works.- One-way
[rating]lets the child drift from the parent until the parent sends a different value. model.required(),alias(the output becomes<alias>Change), and programmaticsubscribe.- When to prefer
input()+output()or a form control instead.
Clarifying questions expected:
- "Is the parent value a signal or a plain field?"
- "Does this need to plug into reactive forms as well?"
Code / implementation expected: Yes — a child with model() used two-way, one-way and against a plain field.