Anuja Patil Anuja Patil - 1 month ago 13
AngularJS Question

Angularjs - ng-options within ng-repeat

I have a simple problem, but don't know how to solve it. The values of partsignalType are not getting populated in my dropdown list.
This is my js code:

var testModule = angular.module('myApp', []);

function testCtrl($scope) {


$scope.participants = [{
partSignalId: '13077223000',
partName: 'abc',
partSignalType: ['H323','SIP']
}]


}

And my html code:

<div ng-controller="testCtrl">
<table border="1" style="width:300px">
<tr>
<th md-column>Select</th>
<th md-column><span>Name</span></th>
<th md-column md-numeric><span>Participant Aliase</span></th>
<th md-column><span>Protocol</span></th>
</tr>
<tr md-row md-select="dessert" md-select-id="name" md-auto-select ng- repeat="participant in participants | filter: search">
<td md-cell><input type="checkbox" ng-model="participant.selected"></td>
<td md-cell>{{participant.partName}}</td>
<td md-cell>{{participant.partSignalId}}</td>
<td md-cell>
<select ng-model="participant.partSignalType" ng-options="partSignalType" required >
<option value="">Select</option>
</select>
</td>
</tr>
</table>
</div>

Answer

Change your select to this

<tr id="formattyperow" ng-repeat="participant in participants | filter: search">
        <td class="label-cell">* Participant type :</td>
        <td>
            <select ng-model="partici" ng-options="partici for partici in participant.partSignalType">
                <option value=""></option>
            </select>
            Value : {{partici}}
        </td>
    </tr>

DEMO

Comments