我仍然是Angular Js的学习者。尝试自定义$ http服务时,我一直收到上述错误。 我的工厂是:
angular.module('starter')
.factory('myFactory', ['$http', function($http){
var myFactory = {};
var events = [];
myFactory.getAllEvents = function(){
$http.get("js/auth.json").then(function(data){
events = data.data;
})
return events;
}
}])

我的控制器是
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
})
.controller('myController', function(myFactory){
var self = this;
self.evenlist = myFactory.getAllEvents();
console.log(self.evenlist)
})

非常感谢你的帮助。