Question presented to candidate:
"Explain what Angular actually does with [(size)]="fontSize". What does it compile to, how does it work with both signals and plain fields, and what does a component need to support it?"
What a strong answer should cover:
[(x)]="v"is syntactic sugar for a property binding[x]plus an event binding(xChange)that writes$eventback.- Any component with an input
xand an outputxChangesupports it:@Input+@Output, or onemodel(). - The compiler emits
ɵɵtwoWayPropertyandɵɵtwoWayListener; the listener callsɵɵtwoWayBindingSet(target, $event), which calls.set()on a writable signal or falls back to assignment. - Hence the right-hand side must be writable: a signal reference or a field, not
v()(NG5002) or a computed. ngModelis just a directive with inputngModeland outputngModelChange.- The data flow stays one-way in each direction; there is no dirty-checked shared variable as in AngularJS.
Clarifying questions expected:
- "Do you want the template-level desugaring or the compiled instructions?"
Code / implementation expected: Yes — a custom two-way bindable component, plus the hand-written equivalent of the sugar.