I have a select option in my Angular page. The options are fetched from the API.
My HTML is :
<div>
<form id="edit-profile" novalidate name="editReservationForm" autocomplete="off" class="form-horizontal" ng-controller="getReservationController">
<fieldset>
<div class="control-group">
<label class="control-label" for="reservation.account.name">Account Name<sup>*</sup></label>
<div class="controls">
<select ng-model="reservation.account.id" required>
<option ng-repeat="p in accounts" value="{{p.id}} ">{{p.name}}</option>
</select>
</div> <!-- /controls -->
</div> <!-- /control-group -->
</fieldset>
</form>
</div>
My controller is :
myApp.controller('getReservationController', ['$scope', 'reservationServices', 'dataTable', '$rootScope', '$location', '$filter', function ($scope, reservationServices, dataTable, $rootScope, $location, $filter) {
reservationServices.getReservations().then(function (result) {
$scope.data = result.data;
$scope.data.currentUser = $rootScope.userInfo.UserId;
});
}]);
Services.js :
myApp.factory('reservationServices', ['apiServices', function (apiServices) {
var factoryDefinitions = {
getReservations: function () {
return apiServices.getFromTalentPool('/reservations').success(function (data) { return data; });
},
getAccounts: function () {
return apiServices.getFromHRIS('/customeraccount').success(function (data) { return data; });
}
}
return factoryDefinitions;
}
]);
The select options displays all the accounts from the API. I want it to only display options that meets the condition data.currentUser==p.account.programManager.id
How can I achieve this?
Please let me know if more details are required in the question.