0
我遇到这个错误,不知道为什么。之前它说'getHeaders'不是一个函数。这是我的代码的片段。AngularJS:ui-grid:TypeError:无法读取未定义的属性'getHeaders'
'use strict';
var first = angular.module('App');
first.controller('NewGridCtrl', ['$scope', '$http', '$timeout', '$modal', '$interval', '$location', 'uiGridConstants', '$filter', '$rootScope', 'GridService',
function($scope, $http, $timeout, $modal, $interval, $location, uiGridConstants, KG, $filter, $rootScope, GridService) {
$("div[id^='nvtooltip']").css("display" , "none");
var id, af;
$scope.pageNumber=0;
$scope.orderByColumn=null;
$scope.gridOptions = {
....
};
GridService.getHeaders().then(
function(result){
$scope.headers = result;
return true;
},
function(error){
console.error(error);
return false;
}
);
$scope.gridOptions.columnDefs = [
$scope.headers
];
}]);
然后我的服务:
first.factory('GridService', function($q, $http){
return{
getHeaders: function(){
return fetchHeaders();
}
}
function fetchHeaders(){
var deferred = $q.defer();
$http.get('v1/headers/').success(function (data) {
deferred.resolve(data);
}).error(function (data, status, headers, config) {
deferred.reject(data);
});
return deferred.promise;
}
});
我错过了什么 - 任何人都可以点我在正确的方向?