当我在http.get中使用params时,我遇到了一些问题。我无法从http获取数据 这是我的JS
.controller('HomeCtrl', function ($scope, kaka, $ionicPopup, $http){
$scope.item ={};
$scope.code = {};
$scope.sizes = [ {code: 123456789, name: 'Modul 1'}, {code: 864369038796946, name: 'Modul 4'},
{code: 864369038803833, name: 'Modul 5'}, {code: 864369038816645, name: 'Modul 6'},
{code: 864369038797142, name: 'Modul 7'}, {code: 864369038796698, name: 'Modul 8'}];
$scope.update = function(selected) {
$scope.item = selected;
};
var config = {
params: {
tN: "find",
f12: +$scope.item.code
}
};
$http.get('http://192.168.100.13:88/OMG1/web.php', config)
// $http.get('http://192.168.100.13:88/OMG1/web.php?tN=find&f12=123456789')
.success(function(data, status, headers,config){
console.log('data success');
console.log(data); // for browser console
$scope.result = data; // for UI
})
.error(function(data, status, headers,config){
console.log('data error');
})
.then(function(result){
things = result.data;
});
$scope.result = {};
$scope.findbtn = function () {
var lat = parseFloat($scope.result.latitude);
var lng = parseFloat($scope.result.longitude);
var mylatlng = {lat: lat, lng: lng};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 15,
center: {lat: -7.3342266, lng: 112.7650341},
//center: {lat: data[0].lat, lng: data[0].lng},
mapTypeId: 'terrain'
});
var marker = new google.maps.Marker({
position: mylatlng,
map: map,
title: 'Your Motor'
});
};
})
当我在crome调试器中使用params
f12: +$scope.item.code
时出现问题我查看$scope.result
显示错误Undefined variable : msg
但是如果我将params f12
更改为{{ 1}}它正常工作。
我不知道如何解决它,p