【问题标题】:AngularJS orderBy messes up materialize striped classAngularJS orderBy 搞砸了物化条纹类
【发布时间】:2016-11-21 17:06:53
【问题描述】:

我正在使用 ng-repeat 并使用 materlize 的“条纹”类在有角度的页面中制作表格:

table.striped>tbody>tr:nth-child(odd) {
    background-color: #f2f2f2
}

如果我不订购 ng-repeat,它可以正常工作,但如果我在 ng repeat (orderBy: 'Student.firstName') 中添加 orderBy,则只有第一行和最后一行显示为白色,表格的其余部分为阴影.我还尝试使用

在控制器中排序数组
$scope.questionScores = _.orderBy $scope.questionScores, 'Student.firstName' 

并使用

$scope.questionScores = $filter('orderBy')($scope.questionScores, 'Student.firstName') 

但是两者都会导致相同的错误,我可以在不弄乱css的情况下订购结果吗?

【问题讨论】:

    标签: css angularjs angular-material materialize


    【解决方案1】:

    你能告诉我 questionScores 中的数据是什么样的吗?

    我在 plunker 中尝试了您的方案,我看到条纹按预期出现。

    https://plnkr.co/edit/ilh6grH2tERRglfhIipp

    var app = angular.module('plunker', []);
    
    app.controller('MainCtrl', function($scope, $filter) {
        $scope.questionScores = [
        {'name' : 'z'},
        {'name' : 'b'},
        {'name' : 'x'},
        {'name' : 'c'},
        {'name' : 'd'},
        {'name' : 'a'},
        {'name' : 'n'},
        {'name' : 'f'}
    ];
    
    $scope.questionScores = $filter('orderBy')($scope.questionScores, 'name') 
    });

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多