【问题标题】:IONIC: unable to get records from two `ng-repeat`IONIC:无法从两个“ng-repeat”获取记录
【发布时间】:2017-10-20 10:46:13
【问题描述】:

我是 ionic 框架的新手。目前我正在开发 ionicsidemenu 应用程序。我想根据日期显示记录,将日期作为标题,并且相应的日期有多个记录。

为此,我有两个web services 一个用于标题日期,另一个用于按日期记录。在我的 HTML 文件中,我有两个 ng-repeat 一个用于显示标题日期。现在我无法理解如何获取特定日期的记录,因为必须将日期发送到 Web 服务以获取记录。

我试过这个:

 <div ng-repeat="d in dates track by $index">
 <h2>d.edate</h2>
 <div ng-init="datewiserecords(d.edate);" >
 <div ng-repeat="n in res1  track by $index" class="text-white"  >
 </div></div></div>

但它不起作用。请帮助我。

【问题讨论】:

  • 尝试打印{{dates}}{{res1}},这样你就会知道它是否有价值

标签: android html angularjs ionic-framework


【解决方案1】:

我不确定你在找什么,但我理解这个问题的方式让我给你一个解决方案如下:

我的解决方案:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">
    <ul>
        <li ng-repeat="get_date in dates">
            <h2>{{get_date.date}}</h2>
            <h4>{{get_date.data}}</h4>
        </li>
    </ul>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
  $scope.dates = [{date:"1",data:"One"},{date:"2",data:"Two"},{date:"3",data:"Three"}];
});
</script>

</body>
</html>

希望对你有帮助

【讨论】:

  • 非常感谢@ram 的回答,但我有多个相同日期和日期的记录,其记录来自另一个网络服务。
猜你喜欢
  • 2018-04-11
  • 1970-01-01
  • 2013-04-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多