首页 > 解决方案 > 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;

相同的代码在我的本地主机中运行良好,并且在部署后面临这个问题。

有人可以告诉我是什么问题吗?

标签: angularjsasp.net-web-apideploymentangularjs-http

解决方案


将 localhost 添加到您已将其部署到的计算机上的主机文件中 - 或将 localhost 替换为完全限定的域名。

https://en.wikiversity.org/wiki/Hosts_file/编辑


推荐阅读