October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Angular NG0955: How to Fix Duplicate Track Keys in @for

NG0955 means an Angular @for track expression returns duplicate keys. Find the collision and use a unique, stable property such as an item ID.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular reports NG0955 when an @for block’s track expression returns the same key for multiple items. Use a key that uniquely identifies each item—usually a stable property such as id or uuid—so Angular can associate each record with the right DOM view.

What NG0955 means

A track key tells Angular which rendered DOM view belongs to each item in an @for collection. NG0955 means at least two items produce the same key. The objects themselves may be different: the problem is that the chosen tracking expression does not distinguish them.

As an Amazon Associate I earn from qualifying purchases.

For example, two records can have different keys but share the same display value. Tracking by that repeated value creates a collision:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
@for (item of items; track item.value) {
  {{ item.value }}
}

Angular’s NG0955 guide demonstrates this issue with repeated values. With duplicate keys, Angular may associate a DOM node with the wrong same-key item while moving or destroying nodes. Angular also documents a reconciliation performance penalty because duplicate keys require more sophisticated, slower data structures.

How to find and fix the duplicate key

  1. Find the @for block named in the warning and inspect the expression after track.

  2. Check the collection for repeated values in that expression. Names, statuses, categories, and display text often describe an item without uniquely identifying it.

  3. Switch to a property that is unique for every item, such as item.id or item.uuid. If the data has no unique identifier, consider adding one.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Check the entire collection again after updates. The tracking value must be unique among all items rendered at the same time.

For example, if key is unique while value may repeat, track by key:

@for (item of items; track item.key) {
  {{ item.value }}
}

In Angular’s example, the repeated value causes the collision and the distinct key property is the correction.

Choose a tracking expression that fits the collection

The right key depends on whether items stay in place and whether the key continues to represent the same logical item as data changes. Angular’s @for API guidance and control-flow guide describe the available approaches.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Collection or candidate When it fits What to check
item.id, item.uuid, or another unique property Best fit for dynamic collections with insertions, deletions, or reordering The value is unique for every rendered item and follows the same logical item across updates.
$index A collection that never changes Angular describes index tracking as straightforward for static collections. For changing collections, an index identifies a position, not the item that moves into or out of it.
Item reference identity Only when no better tracking option is available Angular cautions that tracking by object reference can make rendering updates significantly slower.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

NG0955 versus NG0956

NG0955 is specifically about multiple items producing the same key. NG0956 is a separate warning: tracking by object identity can cause Angular to recreate the DOM structure, often when immutable updates create new object instances for the same logical records. Angular’s NG0956 guide also recommends tracking with a unique property such as an ID.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.