Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs-bug(mat-selection-list): Mat Selection List example is limited to html templating #25894

Open
DanielAJL opened this issue Oct 29, 2022 · 0 comments · May be fixed by #29348
Open

docs-bug(mat-selection-list): Mat Selection List example is limited to html templating #25894

DanielAJL opened this issue Oct 29, 2022 · 0 comments · May be fixed by #29348
Labels
area: material/list docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@DanielAJL
Copy link

DanielAJL commented Oct 29, 2022

Documentation Feedback

It would be really nice if there could be some example implemented that can bind data to the component inside the *.component.ts file. The current example only seems to work with HTML templating, but what if we want to retrieve the value outside of the HTML?

Current mat list with single selection example:

<mat-selection-list #shoes [multiple]="false">
  <mat-list-option *ngFor="let shoe of typesOfShoes" [value]="shoe">
    {{shoe}}
  </mat-list-option>
</mat-selection-list>

<p>
  Option selected: {{shoes.selectedOptions.selected[0]?.value}}
</p>

As a proposed example it would be nice to have a Reactive Forms approach where we can retrieve the data from the FormGroup and even validate it right away before the data. I think this approach would also open up the data to be displayed as well as received.
Some kind of example proposal:

<form id="exampleId" [formGroup]="matListExampleFormGroup">
  <mat-selection-list #list formControlName="experienceLevel" [multiple]="false">
    <mat-list-option *ngFor="let exp of experiences" [value]="exp">
      {{exp}}
    </mat-list-option>
  </mat-selection-list>
</form>

I checked back the version history and noticed the same example from v6 - v14 (slightly different as we approach old versions).

Affected documentation page

https://material.angular.io/components/list/examples

@DanielAJL DanielAJL added docs This issue is related to documentation needs triage This issue needs to be triaged by the team labels Oct 29, 2022
@mmalerba mmalerba added feature This issue represents a new feature or feature request rather than a bug or bug fix area: material/list and removed needs triage This issue needs to be triaged by the team feature This issue represents a new feature or feature request rather than a bug or bug fix labels May 25, 2023
@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Jun 1, 2023
MichelleRetroRabbit added a commit to MichelleRetroRabbit/components that referenced this issue Jun 27, 2024
…plating

Updated the single selection list example from a template-driven form to a reactive form.

Fixes angular#25894
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/list docs This issue is related to documentation P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
3 participants