Answer the question
In order to leave comments, you need to log in
How to submit a select value in a form?
<form ng-submit="send_ticket()">
<div class="modal-body">
<div class="form-group">
<label for="ticketSubject">Тема</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">Услуга</label>
<select class="form-control" ng-model="ticketData.service" id="ticketService" ng-options="opt as opt.id for opt in services">
<option value="">Выберите услугу</option>
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-white" ng-click="cancel()">Закрыть</button>
<button type="submit" class="btn btn-primary">Отправить</button>
</div>
</form>
controller('ServicesCtrl', function($scope, $http) {
$http.get('/links/services')
.success(function(data) {
$scope.services = data;
});
})
[
{"id": "1", "desc": "Описание", "date": "Дата", "status": "success"},
{"id": "2", "desc": "Описание", "date": "Дата", "status": "success"},
{"id": "3", "desc": "Описание", "date": "Дата", "status": "success"},
{"id": "4", "desc": "Описание", "date": "Дата", "status": "success"},
{"id": "5", "desc": "Описание", "date": "Дата", "status": "success"}
]
$scope.send_ticket = function() {
$http.post('http://example.com/example.php', $scope.ticketData)
};
Answer the question
In order to leave comments, you need to log in
Show the value of $scope.services and what should be sent in ticketData.service to the server? It feels like you don't want to send the whole opt object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question