PRADEEPKUMAR D PRADEEPKUMAR D - 2 months ago 8
AngularJS Question

Angular List refresh/update issue, while creating new list item, service(getAll) call not happeneing

Angular List refresh/update issue, while creating new list item



dashboard-controller.js - on dashboard.html

.controller('DashboardController',
function ($scope, $state, eventService, storage) {

eventService.getEventList(storage.getCurrentUser().id).then(function (response) {
c.eventList = response;
});


event-controller.js - on create-event.html

.controller('EventController',
function ($scope, $state, eventService, storage) {
this.createEvent = function () {
eventService.create(event).then(this.onResponseSuccess, this.onResponseError);
};
this.onResponseSuccess = function (payload) {
$state.go('app.dashboard');
};


Issue:



First time I can retrieve event list on Dashboard page, but once i created new event and comeback to Dashboard screen, the newly created Event is not updated on the list, When I tried to call getEventList.

Answer

I've cleared the storage by using deleteAll() method and then called the service which is working and getting the latest data list..!

   eventService.deleteAll();
   eventService.getEventList(storage.getCur...
Comments