I have an ng-repeat that contains a filter on one of the items in the repeated list. The filter works fine except when I add an item to the ng-repeated array. The ng-repeat looks something like this:
<div ng-repeat="post in posts">
<div>{{post.created | formatTimestamp}}</div>
<div>{{post.message}}</div>
</div>
The formatTimestamp filter definitely works, and is probably too long to list here, so I'll omit it. The problem I'm having is that when a user makes a new post I unshift the new post in to the posts array. The post shows up as expected, but the formatTimestamp filter doesn't apply. When I refresh the page, then the filter does work. Something about unshifting the new post prevents the filter from applying. I tried using scope.$digest(), but that didn't solve the problem. The handling of the new post is inside a directive and looks like this:
// store the new post in the database, etc.
scope.posts.unshift(data);
scope.$digest(); // didn't have any effect
Any ideas on what I'm doing wrong?