无法获取未定义或空引用的 属性 'get'

Unable to get property 'get' of undefined or null reference

我知道这可能真的很简单,但我遇到了这个错误

无法获取 属性 'get' 未定义或空引用

当我从我的控制器

呼叫我的api时
 rmdsController.$inject = ['$scope', 'rmds'];
function rmdsController($scope, rmds, $http) {

$scope.Calculate = function () {
        alert('made it');
        $("#spinner").show();


          $http.get('/api/rmd/calcRMDdist/')

          .success(function (data) {
              // Do stuff with data.
          })
          .catch(function (err) {
              // Log error somehow.
          })
          .finally(function () {
              // Hide loading spinner whether our call succeeded or failed.
              $scope.loading = false;
          });
    }

依赖注入是一种常用于基础设施组件的模式,它确保一个特定的组件不会直接创建对其他组件的引用。不是直接实例化,每个组件都将接收对所需其他组件(如助手、服务等)的引用,作为其构造函数的参数。在你的情况下是这样的:

rmdsController.$inject = ['$scope', 'rmds', '$http'];

此处,每当此控制器实例化时,$scope、rmds、$http 都会被 Angular 注入。

参考: http://henriquat.re/basics-of-angular/services-dependency-injection/services-and-dependency-injection-in-angularjs.html