ng-repeat directive sort the data when using (key, value)

前端 未结 7 2151
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 09:40

I have a code something like this with ng-repeat = \"(key,value) in data\". In Controller:

  $scope.Dates = {\"Today\":\"30\",
                  \"This Wee         


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 09:47

    This is fixed as of Angular 1.4.

    See details here:

    Previously, the order of items when using ngRepeat to iterate over object properties was guaranteed to be consistent by sorting the keys into alphabetic order.

    Now, the order of the items is browser dependent based on the order returned from iterating over the object using the for key in obj syntax.

    It seems that browsers generally follow the strategy of providing keys in the order in which they were defined...

提交回复
热议问题