날짜가 내림차순으로 주문하고 싶은 ng-repeat가 있습니다 (가장 최근 항목부터).AngularJS ng-repeat orderBy 날짜가 작동하지 않습니다.
그러나 나는 제대로 작동하지 않는 것 같습니다. 인용문 등을 두 번 확인했습니다. 시도했습니다. orderBy:'createdate':reverse
, orderBy:'article.createdate':reverse
및 orderBy:'data.blog.article.createdate':reverse
아무 것도 작동하지 않는 것 같습니다.
<article data-ng-if="article.id == post || post===NULL" data-ng-repeat="article in data.blog.article | orderBy:'createdate':reverse | slice:currentPage*pageSize:currentPage+1*pageSize">
<h2 class="blog-post-title">
<a href="#!/blog/{{article.id}}" title="Permalink to {{article.title.__cdata}}">{{article.title.__cdata}}</a>
</h2>
<span class="blog-post-meta">Posted on {{article.createdate | date:'MMMM dd, yyyy h:mma'}} by {{article.author}}</span>
<div class="blog-post-content" ng-bind-html="article.content.__cdata">{{article.content.__cdata}}</div>
</article>
이 (X2JS를 사용하여 XML에서 JSON 변환) 데이터의 샘플입니다 :
이{
"blog": {
"article": [
{
"id": "1",
"author": "eat-sleep-code",
"title": {
"__cdata": "The first article."
},
"content": {
"__cdata": "\n This is my first article in my test site.\n "
},
"createdate": "2014-05-09"
},
{
"id": "2",
"author": "eat-sleep-code",
"title": {
"__cdata": "The second article."
},
"content": {
"__cdata": "\n This is my second article in my test site. This article's create date is actually earlier.\n "
},
"createdate": "2014-05-08"
}
]
}
}
때를 함께
을 교체해야합니다 일하지 않는다고 말하면서, 무슨 일이 일어나고있는거야? 콘솔 오류가 있습니까? 그들은 단지 올바른 순서로 있지 않습니까? –
콘솔 오류가 전혀 없습니다. 올바른 순서가 아닙니다. 아, 또한 제거하려고 시도 : orderBy에서 반대 그냥 문제가 아니 었는지 확인합니다. 변경 없음. –
이 토론의 참고 자료 http://stackoverflow.com/questions/19876116/angular-orderby-date/25658846#25658846 – MDT