I have a table that display list of data that can be deleted. And in that table, I have checkboxes for the user to select which data will be deleted. And when a delete button is clicked, a modal will appear and in that modal is an input text with ng-model. And its value will be set through javascript/jquery. I want it to be deleted via angularjs $http request. I have observed that it is working only when I input a text in the textfield. But when it is set through javascript, it is not working. This is the input field inside the modal.
<input class="form-control" id="id" ng-value="" ng-model="Thing.id" />
And the modal:
<script type="text/javascript">
$('#delete_item').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget)
var modal = $(this)
var ids=getID_delete.call();
$('.modal-body #id').val(ids) ;
modal.find('.modal-body #message').text('Are you sure you want to delete it?');
});</script>
And here the angular js controller:
mainApp.controller('equipmentController', ['$scope', '$http', function($scope, $http) {
$scope.equipments=[]
$http.get(BASE_URL+'Equipment/getAllEQs').success( function(response) {
$scope.equipments = response
});
$scope.delete = function(Thing) {
$params = $.param({
"id": Thing.id
})
return $http({
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url:BASE_URL+'Equipment/DeleteEQ',
method: "POST",
data: $params,
})
.success(function(response) {
$('#delete_item').modal('hide');
$scope.equipments = response
});
}
}]);