我正在使用 angular-moment-meteor ,当我使用am-time-ago
指令时,如下所示,我就是那个错误。
<time am-time-ago="post.uploadedAt"></time>
Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"post.uploadedAt","newVal":"2015-07-29T01:14:19.873Z","oldVal":"2015-07-29T01:14:19.873Z"},{"msg":"post.uploadedAt","newVal":"2015-07-29T01:11:57.581Z","oldVal":"2015-07-29T01:11:57.581Z"}],[{"msg":"post.uploadedAt","newVal":"2015-07-29T01:14:19.873Z","oldVal":"2015-07-29T01:14:19.873Z"},{"msg":"post.uploadedAt","newVal":"2015-07-29T01:11:57.581Z","oldVal":"2015-07-29T01:11:57.581Z"}],[{"msg":"post.uploadedAt","newVal":"2015-07-29T01:14:19.873Z","oldVal":"2015-07-29T01:14:19.873Z"},{"msg":"post.uploadedAt","newVal":"2015-07-29T01:11:57.581Z","oldVal":"2015-07-29T01:11:57.581Z"}],[{"msg":"post.uploadedAt","newVal":"2015-07-29T01:14:19.873Z","oldVal":"2015-07-29T01:14:19.873Z"},{"msg":"post.uploadedAt","newVal":"2015-07-29T01:11:57.581Z","oldVal":"2015-07-29T01:11:57.581Z"}],[{"msg":"post.uploadedAt","newVal":"2015-07-29T01:14:19.873Z","oldVal":"2015-07-29T01:14:19.873Z"},{"msg":"post.uploadedAt","newVal":"2015-07-29T01:11:57.581Z","oldVal":"2015-07-29T01:11:57.581Z"}]]
任何人都知道如何解决?
答案 0 :(得分:2)
我解决了删除am-time-ago
指令并在控制器上使用moment().fromNow()
的问题:
查看:
<time ng-bind="timeAgo(post.uploadedAt)"></time>
控制器
$scope.timeAgo = function (time) {
return moment(time).fromNow();
};