0

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.

2 Answers2

0

try using $watch

track your event by $watch here is a link which might help you

Community
  • 1
  • 1
md-5h04I3
  • 214
  • 2
  • 12
0

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...