【问题标题】:OnsenUI Loading Ons-List with Remote JSON DataOnsenUI 使用远程 JSON 数据加载 Ons-List
【发布时间】:2016-07-08 17:31:08
【问题描述】:

首先,我是学习过程中的初学者。我一直在尝试使用此代码将远程 json 数据加载到 ons-list 中。有人可以向我解释为什么数据没有加载到列表中吗?我正在使用摩纳卡。我可以在使用 UL 标签时显示数据。它只是不会出现在 ons-list 标签中。非常感谢您的帮助!

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="Content-Security-Policy" content="default-src * data:; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
    <script src="components/loader.js"></script>
    <script src="lib/angular/angular.min.js"></script>
    <script src="lib/onsenui/js/onsenui.min.js"></script>
    <script src="lib/onsenui/js/angular-onsenui.min.js"></script>

    <link rel="stylesheet" href="components/loader.css">
    <link rel="stylesheet" href="lib/onsenui/css/onsenui.css">
    <link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css">
    <link rel="stylesheet" href="css/style.css">



    <script>
        ons.ready(function() {
            console.log("Onsen UI is ready!");
        });
    </script>

    <script>
        var app = angular.module('myApp', []);
          app.controller('customersCtrl', function($scope, $http) {
          $http.get("http://www.w3schools.com/angular/customers.php").then(function (response) {
          $scope.myData = response.data.records;
          });
        });
    </script>



    </head>
    <body>
    <ons-page ng-app="myApp" ng-controller="customersCtrl">
        <ons-toolbar>
        <div class="center">Introduction</div>
        </ons-toolbar>

        <ul>
    <li ng-repeat="x in myData">
    {{ x.Name + ', ' + x.Country }}
    </li>
    </ul>

    <ons-row ng-repeat="x in myData">
    <ons-col>{{ x.Name }}</ons-col>
    <ons-col>{{ x.Country }}</ons-col>
    </ons-row>

    <ons-list ng-controller="customersCtrl">
    <ons-list-item ng-repeat="x in myData">
    {{ x.Name }}
      </ons-list-item>
    </ons-list>



    </ons-page>
    </body>
   </html>

【问题讨论】:

    标签: angularjs onsen-ui monaca


    【解决方案1】:

    我能够弄清楚。我需要更改下面的代码行。

    var app = angular.module('myApp', ['onsen']);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多