我想调用我在DeliverService
中定义的服务,但是当我从控制器调用它时,出现Cannot read propery getRiders of undefined
错误,不知道为什么会发生这种情况:无法读取未定义的propery getRiders
DeliverService.js
angular.module('Deliver')
.service('DeliverService', ['$http', '$state', '$resource', '$q', 'SettingService', '$localStorage', "MessageService", function($http, $state, $resource, $q, SettingService, $localStorage, MessageService) {
var service = {
getRiders : function(){
return $http.get("Hero.json");
//return $http.get(SettingService.baseUrl + "api/orders");
} }
return service;
}]);
DeliverCtrl.js
use strict';
angular.module('Deliver').controller('DeliverCtrl',['$scope','$state', "SettingService","DeliverService", function($scope, $state, $ionicModal, MessageService, SettingService,DeliverService) {
$scope.riders = [];
DeliverService.getRiders().then(function(response){
$scope.riders = response.data.data;
}, function(error){
});
}]);
是:'D It now now –
Thankyou so much you save m y天 –
@mariasalahuddin很高兴帮助! :) 一旦定时器关闭,你可以接受答案,以便它可以帮助其他人 – tanmay