当我尝试连接到我的网络服务器时,总会出现错误。
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
。
,这是错误: