Reputation: 1442
In the dropdown for different options ID is different with that one API will be called.
HTML :
<select id="select">
<option ng-repeat="p in projects | unique:'pId'" value="{{p.pId}}"
ng-model="p.pName" ng-click="onSelectClick(p.pId)"
ng-selected="{{p.pId == selectedId}}">{{p.pName}}
</option>
</select>
JS:
var pDetails = {
"pId": pId,
"pName": pName,
}
$scope.Projects.push(pDetails);
Upvotes: 1
Views: 952
Reputation: 841
HTML :
<select data-ng-model="Pdetail" data-ng-options="d.Id as d.Name for d in
orderedProjects" class="form-control">`
<option value="">-- Select --</option>
</select>
And in JS:
$scope.orderedProjects = {};
var projectDetails = { "projectId": projectId, "projectName":projectName};
$scope.orderedProjects.push(projectDetails);
Upvotes: 3