【问题标题】:json file not working in android app with ionicjson文件在带有离子的android应用程序中不起作用
【发布时间】:2016-07-11 15:50:01
【问题描述】:

我正在使用 Ionic 框架开发 android app.simple json 文件在我的应用程序中不起作用!相同的应用程序仅适用于本地浏览器,当我在我的手机中运行此应用程序时,该应用程序无法使用 $http 处理 json 文件。我收到此错误,

GET http://localhost:8383/LoginCtrl/www/js/namerecords.jsonnet::ERR_CONNECTION_REFUSED

How to work with json file in mobile,below i attached my code.

Controller.js

app.controller('recordsCtrl',function($scope,$http){
    $http.get('http://localhost:8383/LoginCtrl/www/js/namerecords.json')
            .success(function(response){
                console.log(response.records);
         $scope.persons = response.records;       
    });
});

【问题讨论】:

  • 尝试包含名为whitelist的插件
  • 您需要将“localhost”更改为您的服务器地址!

标签: android json ionic-framework


【解决方案1】:

您需要将 URL 更改为您的服务器地址,而不是“localhost”,因为该服务器未在您的手机中运行。

希望这会有所帮助...

【讨论】:

    【解决方案2】:

    1.$http链接不正确 2.如果您在 ionic 框架中检查 API。仅在移动设备上进行操作。该 api 内容在网络浏览器中不起作用。仅限移动设备。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-22
      • 2016-04-23
      • 2014-08-24
      • 1970-01-01
      • 1970-01-01
      • 2019-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多