0
我是AngularJs的新手。這是我的代碼。在這我想通過獲取系統日期來建立網址。但這些值在jsonp請求時不會被替換。我不知道爲什麼。變量值在運行時不會被替換爲角js
在這裏,當我嘗試手動添加參數。我正在獲取價值。但是,當我嘗試使用變量,我沒有得到輸出。
$scope.getCurrentMonthData = function(){
$scope.date = new Date();
$scope.startday = 1;
$scope.currentday = $scope.date.getDate()+1;
$scope.month = $scope.date.getMonth()+1;
$scope.year = $scope.date.getFullYear();
$scope.start= $scope.year+'/'+$scope.month+'/'+$scope.startday;
$scope.end = $scope.year+'/'+$scope.month+'/'+$scope.currentday;
$scope.url1 = $rootScope.ApiWeatherHost+'/climo/v1/actuals/'+$scope.location_key+'.json?start='+$scope.start+'&end='+$scope.end+'&apikey='+$rootScope.ApiKey;
$scope.url2 = $rootScope.ApiWeatherHost+'/climo/v1/records/'+$scope.location_key+'.json?start='+$scope.start+'&end='+$scope.end+'&apikey='+$rootScope.ApiKey;
$scope.url3 = $rootScope.ApiWeatherHost+'/climo/v1/normals/'+$scope.location_key+'.json?start='+$scope.start+'&end='+$scope.end+'&apikey='+$rootScope.ApiKey;
$http.jsonp($scope.url1).then(function(msg){
console.log(msg.data);
});
$http.jsonp($scope.url2).then(function(msg){
console.log(msg.data);
});
$http.jsonp($scope.url3).then(function(msg){
console.log(msg.data);
});
};
雅我也得到這個。但是當我嘗試發送該網址到JSNOP .. 它不工作..我不知道爲什麼。? – mani 2014-09-23 16:30:00
@mani - 它在開發工具控制檯中說了什麼?如果您檢查返回的HTTP響應是否包含錯誤? – Josh 2014-09-23 17:05:20
輸出即將到來。但它不是JSONP格式。它只給出JSON格式。有時候它也會將JSONP格式作爲輸出。我不知道這件事。我也檢查服務器端的人。從他們的最終沒有問題。 – mani 2014-09-23 17:37:45