Ionic app在设备上没有显示任何内容

时间:2015-09-03 16:07:30

标签: angularjs ionic-framework ionic

我的小应用程序通过“离子服务”运行正常,并在设备(Android)上安装正常。

此应用程序只显示离子卡内的汽车列表。

在浏览器中运行(通过离子服务)一切正常。信息和图像都可以。但是,afer用build.phonegap.com生成apk并安装它,当我运行时,只是在设备上显示标题。

可能出现什么问题?

html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
  </head>
  <body ng-app="myApp">

  <ion-pane ng-controller="myCtrl">
      <ion-header-bar class="bar-stable">
        <h1 class="title">Cars List</h1>
      </ion-header-bar>
      <ion-content>
<div class="list card" ng-repeat="car in cars">

  <div class="item item-avatar" >
    <h2>Cód : {{car.nome}}</h2>


      <div class="item item-body">
        <img class="full-image" src="{{car.url_foto}}">
        <p>{{car.desc}}</p>
      </div>


  </div>




</div>

      </ion-content>
    </ion-pane>
  </body>
</html>


JS :

<!-- begin snippet: js hide: false -->
// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
var myApp = angular.module('myApp', ['ionic'])

myApp.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})



myApp.controller('myCtrl', ['$http','$scope', function($http,$scope){

  var url = '/car_list.json';

  $http.get(url).
    success(function (response) {

      $scope.cars = response.carros.carro;

    }).
    error(function (data, status, headers, config) {
    });


}])

1 个答案:

答案 0 :(得分:0)

问题与json文件的本地路径有关:

    var url = "";
if(ionic.Platform.isAndroid()){
    url = "/android_asset/www/";
}
相关问题