angularjs:orderBy排序对多个字段类型无法正常工作

时间:2017-11-02 21:29:37

标签: angularjs angularjs-ng-repeat angularjs-orderby

我有一个包含多个字段类型(字符串,日期,地址)的表。 orderBy似乎适用于日期和案例编号,它包含字母和数字,但它似乎不能正确地处理地址和字符串。

<thead>
   <tr>
      <th>
         <input type="checkbox" id="selectAll" ng-model="selectAll" ng-click="checkAll()"/>
      </th>
      <th>
         <a href="javascript:void(0)" ng-click="sortType = 'case_num'; sortReverse = !sortReverse">
         <span ng-show="sortType == 'case_num' && !sortReverse" class="fa fa-arrow-down"></span>
         <span ng-show="sortType == 'case_num' && sortReverse" class="fa fa-arrow-up"></span>
         ${Case Number}
         </a>
      </th>
      <th>
         <a href="javascript:void(0)" ng-click="sortType = 'short_desc'; sortReverse = !sortReverse">
         <span ng-show="sortType == 'short_desc' && !sortReverse" class="fa fa-arrow-down"></span>
         <span ng-show="sortType == 'short_desc' && sortReverse" class="fa fa-arrow-up"></span>
         ${Short Description}
         </a>
      </th>
      <th>
         <a href="javascript:void(0)" ng-click="sortType = 'start_date'; sortReverse = !sortReverse">
         <span ng-show="sortType == 'start_date' && !sortReverse" class="fa fa-arrow-down"></span>
         <span ng-show="sortType == 'start_date' && sortReverse" class="fa fa-arrow-up"></span>
         ${Start Date}
         </a>
      </th>
      <th>
         <a href="javascript:void(0)" ng-click="sortType = 'work_location'; sortReverse = !sortReverse">
         <span ng-show="sortType == 'work_location' && !sortReverse" class="fa fa-arrow-down"></span>
         <span ng-show="sortType == 'work_location' && sortReverse" class="fa fa-arrow-up"></span>
         ${Work Location} 
         </a>
      </th>
   </tr>
</thead>
<tbody>
   <tr ng-repeat="item in c.onbCase | orderBy:sortType:sortReverse | filter:searchTable track by $index" ng-if="item.case_visible">
      td><input type="checkbox" id={{item.number}} ng-click="checkboxFunc(item)" ng-model="item.checked" ng-checked="selectAll || item.checked"/></td>
      <td>{{item.number}}</td>
      <td>{{item.short_description}}</td>
      <td>{{item.start_date}}</td>
      <td>{{item.location}}</td>
   </tr>
</tbody>

当我按案例编号和开始日期排序时,条目正确排序。但是,当我尝试按简短描述或位置排序时,它似乎没有正确排序:

enter image description here

enter image description here

我错过了什么吗?谢谢!

0 个答案:

没有答案