TypeError:无法读取属性' post'离子中未定义的

时间:2017-01-04 09:09:30

标签: angularjs ionic-framework

当我尝试连接到我的网络服务器时,总会出现错误。

This是我的代码:

.controller('settingsCtrl', ['$scope','$stateParams',"$cordovaSQLite","$ionicLoading","$ionicPopup","$ionicPlatform","$cordovaPrinter","$cordovaNetwork",

function ($scope, $stateParams,$cordovaSQLite,$ionicLoading,$ionicPopup,$ionicPlatform,$rootScope,$cordovaPrinter,$cordovaNetwork,$http)
{
    $scope.Sync = function()
    {
        $ionicLoading.show();
        var query = "SELECT * FROM bus_transaction";
        var _bustransaction = [];

        $cordovaSQLite.execute(db,query,[]).then(function(res)
        {   
            if(res.rows.length > 0)
            {
                for(var i = 0; i < res.rows.length; i++)
                {
                    _bustransaction.push(res.rows.item(i));
                }       
            }
            console.log( JSON.stringify(_bustransaction) );

        }, function (err)
        {
           $scope.showAlert('Error',err);
           console.error(err);
        });

        var link = 'http://subdomain.domain.com/sync';
        $http.post(link, {update :JSON.stringify(_bustransaction)}).then(function (res)
        {
            console.log(res.data);
        });
    }

我在我的控制器中注入了$http

,这是错误:

enter image description here

0 个答案:

没有答案