Home > Software engineering >  Reference Angular Component creates in *ngFor
Reference Angular Component creates in *ngFor

Time:12-22

I have created some radio-button-groups with the options printed with ngFor in a ngFor loop.

categories:string[] = [category_1, ..., category_n];
options:string[] = [option_1, ..., option_n];

<fluent-radio-group
    *ngFor='let categroy from categories'
    (change)='some_function()'>
    <fluent-radio
        *nfFor='let option from options'
        value=value>
            value
    </fluent-radio>
</fluent-radio-group>

I now want to parse the selected value from each category into the 'some_function()'. How shall I reference these groups and get their value? Thank you already in advance.

I have already tried using an Input variable via ElementRef. This basically works but is quite unhandy as there are many categories.

CodePudding user response:

<fluent-radio-group *ngFor="let category of categories">
<fluent-radio *ngFor="let option of options" (click)="some_function(option)" value="value">{{ option }}</fluent-radio></fluent-radio-group>
  • Related