我对 angular.js 完全陌生,所以对于这样一个愚蠢的问题,我感到很抱歉。但也许它会对其他初学者有所帮助。
我正在从其他人创建的示例项目中学习,但我使用的是本地 IIS(而不是 IIS Express 或 VS 开发服务器)。所以我的基本路径是http://localhost/SampleProject
示例项目包含此 $http.get
$http.get('https://maps.googleapis.com/maps/api/geocode/json',
{
params: params,
headers: { 'Accept-Language': 'en' }
}
)
这适用于“ http://localhost:1234 ”之类的基本 URL ,但在我的情况下,我得到了
Failed to load resource: the server responded with a status of 400 (Bad Request)
因为请求 URL 是
http://localhost/SampleProject/https://maps.googleapis.com/maps/api/geocode/json?sensor=false
谁能告诉我为什么 angular.js 即使使用绝对路径 URL 也要在基本 URL 前添加?
谢谢,汤姆