2016-04-17 4 views
0

ボタンクリックでJSON応答を取得して表示するCordova Ionicアプリケーションを構築しています。ブラウザで正常に動作していますが、アンドロイドには何も表示されません。APIへの呼び出しは、Androidでは応答を返しませんが、ブラウザで正常に動作しています

angular.module('starter', ['ionic']) 

.config(function($ionicConfigProvider) { 
    $ionicConfigProvider.navBar.alignTitle('center'); //align title in center 
}) 

.controller('ControllerOne',[ '$scope', 'freshlyPressed', Ctrl]) 

.service('freshlyPressed', ['$http','$log', freshlyPressed]); 

function Ctrl($scope, freshlyPressed){ 

    $scope.refreshClicked = function(){ 
    freshlyPressed.getBlogs($scope); 
    } 
}; 

function freshlyPressed($http,$log){ 
    this.getBlogs = function($scope){ 
    $http.jsonp("https://public-api.wordpress.com/rest/v1.1/freshly-pressed?callback=JSON_CALLBACK") 
    .success(function(result, posts){ 
     $scope.posts = result.posts; 
    }); 
    }; 
}; 

アンドロイドでアプリをテストする際に例外が発生したかどうかはどのようにわかりますか?

[編集]私はAndroidが新しくて&コルドバ。

答えて

1

何か問題があるかどうかを知る唯一の方法は、.success関数の後に.error関数を追加することです。それ以外の場合はエラーは検出されません。

ここ

は、あなたの現在の状況のた​​めのコード例です:

function freshlyPressed($http,$log){ 
    this.getBlogs = function($scope){ 
    $http.jsonp("https://public-api.wordpress.com/rest/v1.1/freshly-pressed?callback=JSON_CALLBACK") 
    .success(function(result, posts){ 
     $scope.posts = result.posts; 
    }) 
    .error(function(error){ 
     console.log(error); 
    }); 
    }; 
}; 

もののhereが説明するように.error.successは廃止されてきたように、私は非常に、あなたが.then()機能に切り替えることをお勧めします。

+0

ブラウザで正常に動作しています。私はコードに問題はないと思う。インターネット許可も追加されています。まだアンドロイドで働いていない。 –

関連する問題