Tag Archives: Angular select Tag Error

Angular select Tag Error trying to diff ‘2’. Only arrays and iterables are allowed

In the case of binding the select tag to an array of *ngFor, the Error
Error trying to diff ‘2’. Only arrays and iterables are allowed is used. Need to change the bound array to item
in the array error demonstration

   <div class="form-group">
        <label for="partners">Hero partners</label>
        <select class="form-control" id="partners" [(ngModel)]="partners" name="partners">
            <option *ngFor="let partner of partners" [value]="partner.partnerId">{{partner.partnerName}}</option>
        </select>
    </div>

Modified to

   <div class="form-group">
        <label for="selectedPartner">Hero partners</label>
        <select class="form-control" id="selectedPartner" [(ngModel)]="selectedPartner" name="selectedPartner">
            <option *ngFor="let partner of partners" [value]="partner.partnerId">{{partner.partnerName}}</option>
        </select>
    </div>