I am trying to compare values within the context of an ng-repeat directive. Specifically, I need to compare the current value with the previous value in the array being iterated over by ng-repeat. For example, if my array contains the values [2,3], how can I compare the second value with the first?
Update: In my current project, I am displaying the current month and date followed by the next seven days. If one of these days falls into a new month (e.g., January following December), I need to include the name of this new month just before the dates for that specific month.
Example: Dec Tue 30, Wed 31, Jan Thu 1, Fri 2 ....
For all the code related queries, please visit: Fiddle: http://jsfiddle.net/HB7LU/9763/
<div class="row" style="text-align:center;background-color: #930d14; color: white; height: 55px;">
<div class="col" style="border-right: solid 1px #820d13;">
<p style="transform: rotate(270deg);margin-top: 8px;font-size: 10px;font-weight: 600;text-transform: uppercase;">
{{currentMonth}}</p>
</div>
<div class="col" style="border-right: solid 1px #820d13;" ng-repeat="days in totalDays.aryDates">
<p style="font-size: 10px;font-weight: 500;">{{days}}</p>
<p ng-if="totalDays.aryDates[$index-1] !== totalDays.aryDates[$index]" style="transform: rotate(270deg);margin-top: 8px;font-size: 10px;font-weight: 600;text-transform: uppercase;">
{{newMonth}}</p>
</div>