I am having trouble getting my listings page to refresh when a new item has been added. The code below successfully adds a new document to the database from a detail page and then returns to the listings page but the listings page is not updated until I manually press F5.
I have tried adding a $route.reload() statement but that did not help. The problem fixes itself after a few times. In other words the first one or two times a new document is added the listing page does not refresh and show the new item but by the third consecutive addition the listings page will start to refresh every time. I am using Firefox but see the same problem in other browsers.
What code am I missing to make sure that the listings page ng-repeat will re-run after a new item is added to the database? I have the same problem elsewhere in my app when I remove items from the database, the listings page ng-repeat does not re-fire and show the updated list.
securityApp.controller('newDocumentController',
function ($scope, $location, $route, addNewDocumentFactory) {
$scope.addNewDocument = function () {
addNewDocumentFactory.create($scope.document);
alert('New Document has been added');
$location.path('/documents');
};
});
securityApp.factory('addNewDocumentFactory',
function ($resource) {
return $resource('/api/Documents/', {}, {
create: { method: 'POST' }
});
});
<tr ng-repeat="document in documents | orderBy:['-date', '-documentNumber'] | filter:searchText | filter: {date: searchDate}">
various td elements here..
</tr>
tr ng-repeattemplate is associated with which controller? Which template and which controller are affiliated with/documentsand how? ngroute?