What should an Angular @for block track when a list can reorder?
Understand the idea, explain it in your own words and use the rubric to find your next learning gap.
The idea behind the question
A list's tracking expression describes the identity of each item across updates. Stable identity lets Angular associate DOM and component state with the same logical record after reordering.
A user edits the second row, then a new record is inserted at the top. Tracking the position can associate that edit with the wrong record.
A practical way to learn it
Render an editable list using stable IDs and insert an item at the beginning. Verify that a draft and keyboard focus remain associated with the original record.
Open Angular project studioThe related tool opens separately; your interview answer stays here. Written practice is self-guided, without automatic code grading.
Build an explanation you understand
- State what the concept does in plain language.
- Apply it to the example and make your assumptions explicit.
- Explain a trade-off, failure case and how you would test it.
- Distinguish your actual experience from a proposed approach.
How would you explain it?
Single-question timers reset on refresh. Full mock sessions can resume from this browser.
Strengthen your explanation
Compare reasoning, not identical wording. Reference answers describe a possible approach; replace hypothetical statements with truthful details from your own work.
One way to answer
I would track a stable unique record ID for a dynamic list. An index may be appropriate for a genuinely static list, but not as a general identity for editable or reorderable records. I would ensure newly created unsaved rows also have stable local IDs and would not generate new random keys during rendering. Tests should insert, remove and reorder rows while checking focus and local field state. Tracking helps preserve identity; it does not replace validation or make duplicate record IDs acceptable.
What a strong explanation should cover
Tick only the points your own answer addresses. This is self-assessment, not AI scoring.
0 / 3 points self-reportedWatch out for
- Tracking array position for a list whose order changes.
Now go one level deeper
- What happens if the API returns duplicate IDs?
- When would deliberately resetting a row component be useful?
Further reading
Further-reading links support learning; the reference is Sukoaa-authored, not an official employer answer key.