错误:意外请求:尝试在Ionic应用程序中使用http.get时获取

时间:2016-06-06 02:56:33

标签: angularjs ionic-framework angular-ui-router

我使用http服务加载json并将数据绑定到我的UI。但是我收到以下错误。我不是在写任何测试费用。

错误:意外请求:GET

 ionic.bundle.js:25642 Error: Unexpected request: GET 'MYJSONURL'
No more request expected
at $httpBackend (angular-mocks.js:1406)
at sendReq (ionic.bundle.js:23645)
at serverRequest (ionic.bundle.js:23357)
at processQueue (ionic.bundle.js:27879)
at ionic.bundle.js:27895
at Scope.$eval (ionic.bundle.js:29158)
at Scope.$digest (ionic.bundle.js:28969)
at Scope.$apply (ionic.bundle.js:29263)
at HTMLButtonElement.<anonymous> (ionic.bundle.js:62385)
at HTMLButtonElement.eventHandler (ionic.bundle.js:16583)

这是我的服务。

app.service('AuthService', function ($q, $http) {

function getdata() {
    var dataSource = 'MYJSONURL';

    return $http.get(dataSource);

}
return {
    getdata:getdata
};
})

控制器

 app.controller('loginctrl', function ($scope, $state, $ionicPopup, AuthService, AUTH_EVENTS) {
$scope.login = function (data) {
   AuthService.getdata().then(function (response) {
            _this.mydata = response.data;
        }).catch(function (response) {
            console.log(response)
        });
}});

0 个答案:

没有答案