Javascript 角度获取请求不存在';我什么也没表现出来

Javascript 角度获取请求不存在';我什么也没表现出来,javascript,angularjs,Javascript,Angularjs,我正在尝试使用Angular(我的第一个Angular应用程序)发出get请求,但它不起作用 这是app.js文件 var app = angular.module('myApp',[]); app.controller('getCtrl',['$scope',function($scope){ $http.get("http://127.0.0.1:3000/api/Users") .then(function(response){ $scope.users = respons

我正在尝试使用Angular(我的第一个Angular应用程序)发出get请求,但它不起作用

这是app.js文件

var app = angular.module('myApp',[]);
app.controller('getCtrl',['$scope',function($scope){
  $http.get("http://127.0.0.1:3000/api/Users")
  .then(function(response){
    $scope.users = response.data;
  });
}]);
以及index.html文件

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
  </head>

  <body>
    <div ng-app="myApp">
      <div ng-controller="getCtrl">
          <table>
            <tr ng-repeat = "user in users">
               <td>{{user.name}}</td>
               <td>{{user.lastName}}</td>
            </tr>
          </table>
      </div>
    </div>

    <script src="node_modules/angular/angular.js"></script>
    <script src="app.js"></script>
  </body>
</html>
在网页上,结果是空的,就像请求是空的一样,我不知道我是否错过了什么

var app = angular.module('myApp',[]);
app.controller('getCtrl',['$scope','$http',function($scope,$http){
  $http.get("http://127.0.0.1:3000/api/Users")
  .then(function(response){
    $scope.users = response.data;
  });
}]);
固定以下内容

  • 将正确的
    $http
    依赖项注入控制器构造函数

  • response.data拼写错误

固定以下内容

  • 将正确的
    $http
    依赖项注入控制器构造函数

  • response.data拼写错误


打开控制台并读取错误信息。然后添加缺少的注入。
$scope.users=respose.data的输入错误应该是
$scope.users=response.data-响应拼写错误您没有在ur控制器数组中注入$http,函数也没有以这种方式注入
app.controller('getCtrl',['$scope',function($scope)
@Darren Good Observation:)我认为AFS应该先从控制台检查错误,而不是花那么多时间写文章。AFS可以让人们看到控制台错误(如果有)。打开控制台并读取错误。然后添加缺少的注入。
$scope.users=respose.data;
有一个拼写错误应该是
$scope.users=response.data;
-response拼写错误您没有在ur控制器数组中注入$http,函数也没有以这种方式注入
app.controller('getCtrl',['$scope',function($scope)
@Darren良好观察:)我认为AFS应该先从控制台检查错误,而不是花那么多时间写文章。如果有控制台错误,AFS可以让人们看到吗。
var app = angular.module('myApp',[]);
app.controller('getCtrl',['$scope','$http',function($scope,$http){
  $http.get("http://127.0.0.1:3000/api/Users")
  .then(function(response){
    $scope.users = response.data;
  });
}]);