How to send the form the value of the select?

<form ng-submit="send_ticket()">
 <div class="modal-body">
 <div class="form-group">
 <label for="ticketSubject">Subject</label>
 <input class="form-control" type="text" ng-model="ticketData.subject" required id="ticketSubject">
</div>
 <div class="form-group" ng-controller="ServicesCtrl">
 <label for="ticketService">Service</label>
 <select class="form-control" ng-model="ticketData.service" id="ticketService" ng-options="opt as opt.id for opt in services">
 <option value>Select service</option>
</select>
</div>
</div>
 <div class="modal-footer">
 <button type="button" class="btn btn-white" ng-click="cancel()">Close</button>
 <button type="submit" class="btn btn-primary">Send</button>
</div>
</form>


controller('ServicesCtrl', function($scope, $http) {
$http.get('/links/services')
 .success(function(data) {
 $scope.services = data;
});
})


[
 {"id": "1", "desc": "Description", "date": "date", "status": "success"},
 {"id": "2", "desc": "Description", "date": "date", "status": "success"},
 {"id": "3", "desc": "Description", "date": "date", "status": "success"},
 {"id": "4", "desc": "Description", "date": "date", "status": "success"},
 {"id": "5", "desc": "Description", "date": "date", "status": "success"}
]


$scope.send_ticket = function() {
 $http.post('http://example.com/example.php', $scope.ticketData)
 };

The form is submitted all values of an element, how to send only the id?
September 19th 19 at 00:28
1 answer
September 19th 19 at 00:30
Solution
Show the value of $scope.services and what should be sent in ticketData.service on the server? There is a feeling that you don't want to send the entire object opt.
$scope.services added service.id to send how to send id not understood. - Zechariah.Grady commented on September 19th 19 at 00:33
ng-options="opt.id as opt.status for opt in services"

I believe you need. - jodie.Grah commented on September 19th 19 at 00:36
: thanks for the help, the right option for me opt.id as opt.id for opt in services - Zechariah.Grady commented on September 19th 19 at 00:39

Find more questions by tags Angular