angularjs - AngularJs 部署站点 SyntaxError:意外的标识符
问题描述
我开发了一个 ASP.NET WEB API Angularjs 应用程序,在我将它发布到 IIS 服务器后,它在下面代码的 URL 处引发了 Unexpected identifier 错误。
function getAllWeeks() {
var defer = $q.defer();
$http({
method: 'GET',
url: 'http://localhost/PS/api/ItemCements/AllWeeks', --> error here and message: SyntaxError: Unexpected identifier
params: {}
}).then(function successCallback(response) {
$scope.Weeks = response.data;
}, function errorCallback(response) {
});
return defer.promise;
相同的代码在我的本地主机中运行良好,并且在部署后面临这个问题。
有人可以告诉我是什么问题吗?
解决方案
将 localhost 添加到您已将其部署到的计算机上的主机文件中 - 或将 localhost 替换为完全限定的域名。
推荐阅读
- c# - 使用 WebMethod 从数组中获取值
- angular - 将 Angular http 调用迁移到 v6
- c# - 必须在数据库上搜索查询,例如名称并吐出任何相似的内容
- matlab - 如何在 Matlab 中对矢量数据进行数值积分?
- javascript - 尝试插入新事件时 API 日历出现问题
- amazon-web-services - Kubectl:使用 route53 私有托管区域访问 kubernetes 集群
- python - python - 如何在没有重叠的情况下在python中找到字符串中的一些连续字母?
- python - 在 Python 中查询正则表达式模式
- ios - 随机词(有意义的)生成
- python-3.x - 将制表符分隔(\t)文本文件转换为另一个制表符分隔(\t)文本文件,python中没有最后一列