{"record":{"id":"e0901bfc8caa7e6b","repo":"angular/components","slug":"table-text-column-must-have-a-name","errorCode":null,"errorMessage":"Table text column must have a name.","messagePattern":"Table text column must have a name\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cdk/table/text-column.ts","lineNumber":156,"sourceCode":"      throw getTableTextColumnMissingParentTableError();\n    }\n  }\n\n  ngOnDestroy() {\n    if (this._table) {\n      this._table.removeColumnDef(this.columnDef);\n    }\n  }\n\n  /**\n   * Creates a default header text. Use the options' header text transformation function if one\n   * has been provided. Otherwise simply capitalize the column name.\n   */\n  _createDefaultHeaderText() {\n    const name = this.name;\n\n    if (!name && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw getTableTextColumnMissingNameError();\n    }\n\n    if (this._options && this._options.defaultHeaderTextTransform) {\n      return this._options.defaultHeaderTextTransform(name);\n    }\n\n    return name[0].toUpperCase() + name.slice(1);\n  }\n\n  /** Synchronizes the column definition name with the text column name. */\n  private _syncColumnDefName() {\n    if (this.columnDef) {\n      this.columnDef.name = this.name;\n    }\n  }\n}\n","sourceCodeStart":138,"sourceCodeEnd":173,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk/table/text-column.ts#L138-L173","documentation":"MatTextColumn derives a default header text by transforming its `name`; if no name input is provided, _createDefaultHeaderText cannot produce a header and throws in dev mode. The name is also required to register the column with the table.","triggerScenarios":"_createDefaultHeaderText (called from ngOnInit): this.name is empty/undefined and no header text is supplied via projected header cell or defaultHeaderTextTransform option.","commonSituations":"Writing <mat-text-column> and forgetting name=\"...\"; binding [name] to a property that is undefined at init time; dynamically created columns where the name is assigned after ngOnInit already ran.","solutions":["Add the name attribute: <mat-text-column name=\"userName\"></mat-text-column>","Ensure the bound [name] value is set before change detection/ngOnInit (static binding or input setup)","Provide a projected <th mat-header-cell *matHeaderCellDef> instead of relying on the default text","Configure the defaultHeaderTextTransform option only as a transform for existing names, not a substitute for name"],"exampleFix":"// before\n<mat-text-column></mat-text-column>\n// after\n<mat-text-column name=\"email\"></mat-text-column>","handlingStrategy":"validation","validationCode":"const cols = Array.from(hostEl.querySelectorAll('mat-text-column'));\nconst unnamed = cols.filter(c => !c.getAttribute('name') && !c.hasAttribute('ng-reflect-name'));\nif (unnamed.length) throw new Error('Every mat-text-column requires a name');","typeGuard":"function hasName(col: {name?: string}): col is {name: string} & typeof col {\n  return typeof col.name === 'string' && col.name.length > 0;\n}","tryCatchPattern":"try {\n  this.cdr.detectChanges();\n} catch (e) {\n  if (/must have a name/.test(e.message)) {\n    console.error('Add name=\"...\" to each mat-text-column.');\n  }\n}","preventionTips":["Always set the name attribute on mat-text-column","Ensure bound [name] values are available at initialization","Provide projected header cells if relying on custom header text"],"tags":["angular","material","text-column","missing-name"],"backgroundTag":"column-missing-name","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}