2015-11-15 72 views
1

我有这样的代码:为什么我得到错误:http.get不是一个函数

(function() { 
    "use strict"; 

    angular.module("workPlan").controller("workPlanListController", ["workPlans", 
                    "clients", 
                    "inspectionAuthority", 
                    "$http", 
                    "config", 
                    "workPlanServise", 
                    workPlanListController]); 
    function workPlanListController(workPlans, 
            clients, 
            inspectionAuthority, 
            workPlanServise, 
            config, 
            $http) { 
     var self = this; 

     this.workPlanList = workPlans; 
     this.lookups = { 
      client: clients, 
      authority: inspectionAuthority 
     }; 

     this.gridOptions = { 
      expandableRowTemplate: 'app/workPlan/templates/expandableRowTemplate.tmpl.html', 
      expandableRowHeight: 150, 
      enableColumnMenus: false, 
      enableSorting: true, 
      enableFiltering: false, 
      enableToopTip: true, 
      enableHorizontalScrollbar: 0, 
      onRegisterApi: function (gridApi) { 
       gridApi.expandable.on.rowExpandedStateChanged(null, function (row) { 


        if (row.isExpanded) { 
         row.entity.subGridOptions = { 

          columnDefs: [{ name: 'Authority', field: 'authName', cellTooltip: true }, 
             { name: '# Items, field: 'items2inspect', cellTooltip: true }, 
             { name: '% Inspected, field: 'percentage', cellTooltip: true }] 
         }; 

          $http.get(config.baseUrl + "api/workPlan/").success(function (result) { 
           row.entity.subGridOptions.data = result.data; 
          }); 

        } 
       }); 
      } 
     } 
     this.gridOptions.columnDefs = [ 
{ name: 'client, field: 'clientName', cellTooltip: true, headerTooltip: true }, 
{ name: 'sites', field: 'siteNumbers', cellTooltip: true, headerTooltip: true }, 
{ name: 'checkedSites', field: 'siteNumbersInspected', cellTooltip: true, headerTooltip: true }]; 

     this.gridOptions.data = self.workPlanList; 
    } 
})(); 

当我尝试扩大我行获得该行:

$http.get 

错误:$ HTTP。进入不是一个功能。

任何想法,为什么我得到错误?

回答

2

在控制器功能中使用依赖关系时,不应更改依赖关系序列。

代码

angular.module("workPlan").controller("workPlanListController", ["workPlans", 
    "clients", 
    "inspectionAuthority", 
    "$http", 
    "config", 
    "workPlanServise", 
    workPlanListController 
]); 

function workPlanListController(workPlans, 
    clients, 
    inspectionAuthority, 
    $http, //<-- $http should be here, instead of placing it at the end. 
    config, 
    workPlanServise 
) { 

SO Answer here

相关问题