Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs IONIC:从JSON数组加载listview_Angularjs_Ionic Framework - Fatal编程技术网

Angularjs IONIC:从JSON数组加载listview

Angularjs IONIC:从JSON数组加载listview,angularjs,ionic-framework,Angularjs,Ionic Framework,这是我的HTML代码: <!DOCTYPE html> <html ng-app="starter"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>Ionic L

这是我的HTML代码:

<!DOCTYPE html>
<html ng-app="starter">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Ionic List Directive</title>
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>
    <script src="js/jsonCntrl.js"></script>
  </head>

  <body ng-controller="myCntrl">

    <ion-header-bar class="bar-positive">
      <h1 class="title">Items List</h1>
     </ion-header-bar>

    <ion-content>
      <ion-list >
        <ion-item ng-repeat="item in myData">
          {{ item.Name }}
        </ion-item>

      </ion-list>
     </ion-content>

  </body>
</html>
我没有得到一个列表视图,而是像这样的东西


但是,当我使用相同的代码从数组填充数据时,它工作得很好。

使用您拥有的相同代码,并使用5646行检查IONAL.css文件中.item类的样式,否则将使用下面的样式覆盖该类

border-color: #ddd;
background-color: #fff;
color: #444;
position: relative;
z-index: 2;
display: block;
margin: -1px;
padding: 16px;
border-width: 1px;
border-style: solid;
font-size: 16px;
试试这个:

angular.module('starter', []).controller('myCntrl', function($scope,$http) {
    $http
        .get("http://www.w3schools.com/angular/customers.php")
        .then(function(response) {
            $scope.myData = angular.fromJson(response.data.records);
    }); 
});

当我将.then改为.success时,它甚至没有加载JSON数组,而是显示一个空屏幕。我使用相同的API调用检查了该屏幕,并能够获得您想要的列表。请再次检查控制器
angular.module('starter', []).controller('myCntrl', function($scope,$http) {
    $http
        .get("http://www.w3schools.com/angular/customers.php")
        .then(function(response) {
            $scope.myData = angular.fromJson(response.data.records);
    }); 
});