I need to send the variables lat and lng through the form and send them to php
.controller(‘HomeCtrl’, function($scope, $http){
var defaultHTTPheaders={
‘Content-Type’: ‘application/json’,
‘Accept’: ‘application/json’
};
$http.defaults.headers.post = defaultHTTPheaders;
$scope.enviar = function () {
$http({
method: 'post',
url: 'http://www.efruver.com/ubicarproveedores.php',
headers: {'Content-Type': 'application/json'},
data:JSON.stringify({
lat: $scope.lat,
lng: $scope.lng
})
}).success(function (data) {
console.log(data);
}).then(function (response) {$scope.categoria = response.data.records;});
}
});
<ion-item class="item-divider" id="inicio-list-item-divider2"> Distancia proveedor</ion-item>
<ion-item class="range range-positive" id="inicio-range2">Distancia<input type="range" name="volume" value="50" min="0" max="100" step="2" color="secondary" ng-model="rangeValue" ng-change="drag(rangeValue)" >
<div> {{rangeValue}}km</div>
</ion-item>
<button id="inicio-button1" type="submit" value="Enviar" ng-click="enviar()" class="button button-assertive button-block">Buscar</button>
</form>
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$lat=$_GET["lat"];
$lng=$_GET["lng"];
$distance =5;
?>