从NG-重复删除自动排序 [英] Remove Automatic ordering from ng-repeat

查看:171
本文介绍了从NG-重复删除自动排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSON对象。它不以升序排序。

I have a json object. It is not ordered in ascending order.

 $scope.myData = {
        "MAX" : "some value",
        "Forms" : "some value",
        "Grids And Tables" : "some value",
        "Navigation" : "some value",
        "Services & APIs" : "some value"
  }

我用NG-重复用于显示在我的HTML模板吧。我得到的结果,但是,在订单已更改为按升序排列。

I used ng-repeat for showing it in my html template. I got the result but, the order has changed in to ascending order.

Forms
Grids And Tables
MAX
Navigation
Services & APIs

如何从自动排序prevent角JS?

How to prevent angular js from automatic ordering?

勾选此链接

推荐答案

的建议,这是不可能的对象键进行排序。买你可以排序在使用这些对象键创建阵列 -

As suggested, it's not possible to sort object keys. Buy you can sort over an array created using those object keys -

$scope.keys = Object.keys($scope.myData);
<ul>
  <li ng-repeat="key in keys">
    {{key}} - 
    {{myData[key]}}
  </li>
</ul>

这篇关于从NG-重复删除自动排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆