2016-04-03 10 views
2

イオンと角が新です。ここではJSONデータをイオンと角のリストにデータが表示されない

{"menu":[{"name":"Mixed Veg Wrap","image":"mix-veg-wrap.jpg","category":"WRAPS, Light Bites","spice_meter":"1","description":"Spicy mixed vegetables :)","rating":"3","price":"35","is_veg":"yes"},{"name":"Egg Wrap","image":"egg-wraps.jpg","category":"WRAPS, Light Bites","spice_meter":"0","description":"Double egg coating with Onion and Sauces!","rating":"4.9","price":"36","is_veg":"no"},{"name":"Cheese Melt Paneer","image":"cmp.jpg","category":"WRAPS, Special","spice_meter":"0","description":"Paneer in Reshmi Masala with melted Cheese","rating":"4.5","price":"91","is_veg":"yes"},{"name":"Prawns Tikka","image":"prawan.jpg","category":"WRAPS, Special","spice_meter":"1","description":"Prawns in spicy tikka masala.","rating":"3.5","price":"110","is_veg":"no"} 

をリストを作成しようとすると、ここでapp.js

// 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' 
angular.module('starter', ['ionic']) 

.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(); 
    } 
    }); 
}).controller('ListController', ['$scope', '$http', function($scope, $http) { 
    $http.get('js/data.json').success(function(data) { 
     $scope.menu = data; 
    }); 
}]); 

は私のindex.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="starter"> 
    <ion-pane> 
     <ion-header-bar class="bar-dark"> 
     <h2 class="title">Artist List</h2> 
     </ion-header-bar> 
     <div class="bar bar-subheader 
     item-input-inset bar-light"> 
     <label class="item-input-wrapper"> 
      <i class="icon ion-search placeholder-icon"></i> 
      <input type="search" placeholder="Search"> 
     </label> 
     </div> 
     <ion-content ng-controller="ListController" 
     class="has-subheader"> 
     <ion-list> 
      <ion-item ng-repeat='item in menu' 
      class="item-text-wrap"> 
      <h2>{{item.name}}</h2> 
      <img ng-src="img/{{item.image}}" /> 
      <h3>{{item.category}}</h3> 
      <h3>{{item.spice_meter}}</h3> 
      <h3>{{item.description}}</h3> 
      <h3>{{item.rating}}</h3> 
      <h3>{{item.price}}</h3> 
      <h3>{{item.is_veg}}</h3> 
      </ion-item> 
     </ion-list> 
     </ion-content> 
    </ion-pane> 
    </body> 
</html> 

ナットP/O結果である私のコントローラでありました空白リスト コンソールを確認しました

ionic.bundle.js:17752 XHR終えロード:GET "http://192.168.1.201:8100/js/data.json" ionic.bundle.js @(匿名関数):。17752sendReq @ ionic.bundle.js:17553serverRequest ionic.bundle.js @:17269processQueue @イオン.bundle.js:21114(匿名 機能)ionic.bundle.js @:。21130Scope ionic.bundle.js @ $ evalを:。22326Scope $ ionic.bundle.js @ダイジェスト:。22142Scope $ ionic.bundle @ を適用.js:22431bootstrapApply @ ionic.bundle.js:9373invoke @ ionic.bundle.js:12110doBootstrap @ ionic.bundle.js:9371bootstrap @ ionic.bundle.js:9391angularInit @ ionic.bundle.js:9285(匿名 機能)@ ionic.bundle.js:34050trigger @ ionic.bundle.js:10669eventHandler @ ionic.bundle.js:10939

助けてください!

答えて

1

ブラウザのコンソールhttp://192.168.1.201:8100/js/data.jsonに表示されているパスが正しいことを確認してください。その後

だけではなく、data

.controller('ListController', ['$scope', '$http', function($scope, $http) { 
    $http.get('js/data.json').success(function(data) { 
     $scope.menu = data.menu; //assigning menu 
    }); 
}]); 
+0

のメニューを使用data.menuを割り当てる際には、本当に助け..クイックヘルプのために...いくつかの非常にありがとう! –

関連する問題