Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140042

Angular reactive form *ngFor loop, cannot read 'property' of undefined

$
0
0

StackBlitz example

I'm trying to loop dynamic values to create radio button items on my form. I have managed to display the three radio buttons coming from my data:

radiot: [
        {
          section: "yes",
          sectionCode: "1"
        },
        {
          section: "no",
          sectionCode: "2"
        },
        {
          section: "maybe",
          sectionCode: "3"
        }
      ]

The problem is I cant display the option of "section".

e.g.

<div class="form-check-inline" *ngFor="let item of personal.radioButtons.radiot; let i = index">

    <label for="yes" class="col-12 customradio"><span>{{item[i].section}}</span>
        <input value="{{item[i].section}}" id="{{item[i]}}" type="radio" [formControlName]="i"/>
        <span class="checkmark"></span>
    </label>
</div>

What am I doing wrong? getting the error - Cannot read property 'section' of undefined

StackBlitz example


Viewing all articles
Browse latest Browse all 140042

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>