我想調用我在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