orderBy:' date'错误返回" [orderBy:notarray]"

时间:2016-06-21 11:22:35

标签: javascript angularjs

我似乎无法通过"日期"来订购我的ng-repeat。键入我的数组。它返回的错误是[orderBy:notarray]。我有一种感觉,因为我的数组中的Date键是一个字符串,而不是一个值,但我对如何解决这个问题一无所知。我如何按日期订购呢?

HTML

  <div class="list-group-item" ng-repeat="post in posts | orderBy:'Date':true" ng-if="post.Date < yesterday">
                 <div class="post-intro" ng-click="showDetails = !showDetails">
                    <h3>{{post.Title}}</h3>
                    <h4>
                        {{post.Company}}
                    </h4>
                </div>
                <div class="post-details" ng-show="showDetails">
                    <p>{{post.Description}}</p>
                    <div class="post-footer">
                    </div>
                </div>
            </div>

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

app.controller("boardController", function($scope,$filter) {
    var today = new Date();

    $scope.today= $filter('date')(today, 'yyyy-MM-dd');

    $scope.yesterday = $filter('date')(new Date().setDate(today.getDate() - 1), 'yyyy-MM-dd');

    $scope.lastWeek = $filter('date')(new Date().setDate(today.getDate() - 7), 'yyyy-MM-dd');

    $scope.posts = 
       { 
        SGIPixel: {
            "Title" : "Y",
            "Company" : "Z",
            "Date" : "2016-06-19",
            "Description" :  "",
            "URL" : "",
       },
        ShowtimeNetworks: {
            "Title" : "X",
            "Company" : "A",
            "Date" : "2016-06-20",
        }
    }
});

0 个答案:

没有答案