I want to separate the display from the previous element during ng-repeat
Similar to this question, I would like to put a partition on the list when the date changes (e.g., when I straddle the date from June 9th to June 10th), but it doesn't work, so please give me some advice.
In the answer above,
<div ng-repeat="item in items">
<div>{{items[$index-1].created_at===item.created_at?\u00A0':item.created_at}}</div>
<div>{{item.item_id}}</div>
</div>
It was written that you can write like this.So,
<ons-row class="shikiri"ng-if="results[$index-1].attributes.updateDate|date:"MM/dd"!==
result.attributes.updateDate | date: "MM/dd"">
In and ng-if, I wrote the conditions for comparing dates with reference to the answer above. |date: "MM/dd"
appears to be an error.
Since it is an object from nifty mbaas, we are getting the date as .attributes.updateDate.
(The date data is in the format 2015-06-10T15:15:48.754Z.)
Since ng-if starts with で, enclose MM/dd with 』 『 instead of 』 で
This seems to be all right, but for some reason, it didn't work properly without toString the results.
var app=angular.module("app", []);
app.controller('mainController',['$scope', function($scope){
vara = new Date (2015, 5, 9, 12, 0)
$scope.items=[
{
"item_id": 1,
"user_id": 1,
"created_at": "2015-06-10T15:15:48.754Z"
},
{
"item_id"—2,
"user_id": 1,
"created_at": "2015-06-10T10:15:48.754Z"
},
{
"item_id"—3,
"user_id": 1,
"created_at": "2015-06-09T15:15:48.754Z"
},
{
"item_id"—4,
"user_id": 1,
"created_at": "2015-06-09T10:15:48.754Z"
},
{
"item_id"—5,
"user_id": 1,
"created_at": "2015-06-09T05:15:48.754Z"
}
];
}
]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.js"></script>
<div ng-app="app">
<div ng-controller="mainController">
<div ng-repeat="item in items">
<hrng-if="$index!=0&&(items[$index-1].created_at | date: 'MM/dd': 'UTC').toString()!==(item.created_at | date: 'MM/dd': 'UTC').toString()">
<div>{{item.item_id}}</div>
<div>pre: {{items[$index-1].created_at | date: 'MM/dd': 'UTC'}}</div>
<div>cur: {{item.created_at | date: 'MM/dd': 'UTC'}</div>
</div>
</div>
</div>
© 2024 OneMinuteCode. All rights reserved.