AngularJS中的地图顺序自动更改

时间:2017-04-25 01:13:33

标签: javascript angularjs

我有一个带有键和值对的组元素的地图对象。键是字符串日期,值为消息。当我使用$scope打印时,我将地图对象存储在一个console.log变量中。我将过去日期中的数据作为按键升序获取当前日期。

请参阅以下代码段以获取地图对象。但是当我在html中看到订单自动更改时。有人可以说为什么订单会改变吗?

MAP的JSON数据

{"Mar 13, 2017":[{"msg":"Hello Mar 13","created":1489404180586},
"Mar 22, 2017":[{"msg":"Hello Mar 22","created":1490185383843}],
"Apr 16, 2017":[{"msg":"Hello Apr 16","created":1492329078569}],
"Apr 24, 2017":[{"msg":"Hello Apr 24","created":1493055290741},
"Apr 25, 2017":[{"msg":"Hello Apr 25","created":1493081729979}]}

HTML

<div ng-repeat='(key, value) in map'>    
 <p><span>Apr 16,2017</span></p>
 <div ng-repeat="msg in value | orderBy : 'created'">
 <div>
   <div>           
      <span>Hello Apr 16</span>
   </div>
   <p><span>Apr 24,2017</span></p>
 <div ng-repeat="msg in value | orderBy : 'created'">
 <div>
   <div>           
      <span>Hello Apr 24</span>
   </div>
   <p><span>Apr 25,2017</span></p>
 <div ng-repeat="msg in value | orderBy : 'created'">
 <div>
   <div>           
      <span>Hello Apr 25</span>
   </div>
   <p><span>Mar 13,2017</span></p>
 <div ng-repeat="msg in value | orderBy : 'created'">
 <div>
   <div>           
      <span>Hello Mar13</span>
   </div>
   <p><span>Mar 22,2017</span></p>
 <div ng-repeat="msg in value | orderBy : 'created'">
 <div>
   <div>           
      <span>Hello Mar22</span>
   </div>
</div>
</div>

0 个答案:

没有答案