AngularJS ng-repeat orderBy不工作

时间:2015-07-06 19:09:09

标签: angularjs

我正在尝试在表格中使用Angular的orderBy来订购对象列表。

<div ng-repeat="processing in model.Processings" class="onePaddingBottom">
    <table datatable="ng" class="table-bordered">

        <tbody >
            <tr ng-repeat="pointer in processing.ProcessingPointers | orderBy:'Sequence'" >
                <td class="col-md-1">

                    <input type="text" ng-model="pointer.Sequence" readonly=""/>
                </td>
                <td><input ng-model="pointer.Name" /></td>
            </tr>
        </tbody>
    </table>
</div>

控制器

$scope.model = new Model()

模型

var Model = function () {
    this.Processings = [];  // array of Processings seen below
    this.categories = [];
    this.Rules = [];
};

var Processing = function (carrierService) {
    this.ProcessingId = 0;
    this.categoryId = 1;
    this.Rules = [];
    this.category = "";
    this.ProcessingPointers = [];  // array of Pointers seen below.
}

var Pointer = function () {
    this.ProcessingID = 0;
    this.ProcessingRuleTypeID = 0;
    this.Sequence = 0;
    this.Name = "";
    // other data items 
}

填充我的表时,对象的顺序不正确。序列中的顶部项目始终是最高项目,其余项目按顺序排列。因此,如果我的指针阵列是

var pointers = [
    {Sequence: 1, Name:"John"},
    {Sequence: 2, Name:"Jane"},
    {Sequence: 3, Name:"Joe"},
    {Sequence: 4, Name:"Jill"}
];

订单总是4,1,2,3。导致这种排序的原因是什么?

更新

下面是截图。

enter image description here

序列似乎适用于IE,但不适用于Chrome或Firefox。

0 个答案:

没有答案