{"record":{"id":"6c55ac85c3948c03","repo":"angular/components","slug":"cdkselectall-missing-cdkselection-in-the-parent","errorCode":null,"errorMessage":"CdkSelectAll: missing CdkSelection in the parent","messagePattern":"CdkSelectAll: missing CdkSelection in the parent","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cdk-experimental/selection/select-all.ts","lineNumber":100,"sourceCode":"    this._configureControlValueAccessor();\n  }\n\n  private _configureControlValueAccessor() {\n    if (this._controlValueAccessor && this._controlValueAccessor.length) {\n      this._controlValueAccessor[0].registerOnChange((e: unknown) => {\n        if (e === true || e === false) {\n          this.toggle();\n        }\n      });\n      this.checked.pipe(takeUntil(this._destroyed)).subscribe(state => {\n        this._controlValueAccessor![0].writeValue(state);\n      });\n    }\n  }\n\n  private _assertValidParentSelection() {\n    if (!this._selection && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('CdkSelectAll: missing CdkSelection in the parent');\n    }\n\n    if (!this._selection.multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n      throw Error('CdkSelectAll: CdkSelection must have cdkSelectionMultiple set to true');\n    }\n  }\n\n  ngOnDestroy() {\n    this._destroyed.next();\n    this._destroyed.complete();\n  }\n}\n","sourceCodeStart":82,"sourceCodeEnd":113,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/cdk-experimental/selection/select-all.ts#L82-L113","documentation":"CdkSelectAll must live inside a CdkSelection parent (or be bound to one), from which it injects the selection state. During ngOnInit, _assertValidParentSelection throws this dev-mode error when the parent CdkSelection could not be resolved, meaning cdk-select-all was used without cdk-selection. A second check on the same line ensures multiple-selection is enabled before the 'multiple' error fires.","triggerScenarios":"Placing <cdk-select-all> outside any <cdk-selection> component so the injected parent (_selection) is undefined when ngOnInit runs.","commonSituations":"Copying a select-all checkbox into a standalone component/template without the selection wrapper; conditional rendering that removes the cdk-selection ancestor; misunderstanding that cdk-select-all requires cdk-selection as parent.","solutions":["Wrap the select-all in a CdkSelection: <cdk-selection [multiple]=\"true\"> <cdk-select-all>Select all</cdk-select-all> </cdk-selection>.","If select-all lives in a separate component, move it inside the cdk-selection template so the content/parent injection resolves.","Verify the template hierarchy — cdk-select-all must be a descendant (content-projected or nested) of cdk-selection."],"exampleFix":"// before\n<cdk-select-all>Select all</cdk-select-all>\n// after\n<cdk-selection [multiple]=\"true\">\n  <cdk-select-all>Select all</cdk-select-all>\n</cdk-selection>","handlingStrategy":"validation","validationCode":"const sel = document.querySelector('cdk-selection');\nif (!sel || !sel.querySelector('cdk-select-all')) {\n  // cdk-select-all is not inside a cdk-selection\n}","typeGuard":null,"tryCatchPattern":"ngAfterViewInit() {\n  if (!this.parentElement.closest('cdk-selection')) {\n    throw new Error('cdk-select-all requires a cdk-selection parent');\n  }\n}","preventionTips":["Always template cdk-select-all inside cdk-selection.","Keep select-all and selection list markup in the same component template.","Use an editor snippet/partial that emits the full cdk-selection wrapper."],"tags":["angular","cdk","selection","experimental","missing-parent"],"backgroundTag":"missing-parent-component","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}