angular-moment-meteor Uncaught Error:[$ rootScope:infdig] 10 $ digest()迭代次数达到

时间:2015-07-29 03:38:23

标签: angularjs meteor angular-meteor

我正在使用 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"}]]

任何人都知道如何解决?

1 个答案:

答案 0 :(得分:2)

我解决了删除am-time-ago指令并在控制器上使用moment().fromNow()的问题:

查看:

<time ng-bind="timeAgo(post.uploadedAt)"></time> 

控制器

$scope.timeAgo = function (time) {
    return moment(time).fromNow();
};