How to use plot.loadedNotifications(function(notifications) in Ionic services

17 views
Skip to first unread message

Nilesh Goswami

unread,
Feb 1, 2016, 4:07:49 AM2/1/16
to plot-users
Currently I have, plot.loadedNotifications(function(notifications){}) in my controller of Ionic app, where I show all the cached notifications in ng-repeat view.
But the list doesnt show at first time. I want to create a service to retrieve LoadedNotifications but I dont know how.
can anybody please help create a service/factory which returns "notifications" from " plot.loadedNotifications(function(notifications)"

Mark van der Tol

unread,
Feb 1, 2016, 5:55:19 AM2/1/16
to plot-users
Hi Nilesh,

When you want to update something in a scope object from a callback of a different library, you have to tell Angular that you're doing so. One way to do this is wrapping the assignment in a function called by $timeout.

For example:
plot.loadedNotifications(function(notifications){
  $timeout
(function() {
    $scope
.notifications = notifications;
 
});
});

Does this solve your issue?

Kind regards,
Mark van der Tol
Plot Projects

Nilesh Goswami

unread,
Feb 7, 2016, 6:13:41 AM2/7/16
to plot-users
Hi Mark,

I tried it using $timeout and IonicLoader like this,

plot.loadedNotifications(function(notifications){
      $timeout(function() {
        $ionicLoading.hide();
        $scope.items = notifications;
      }, 2000);
    });

But still ng-repeat list is empty for the first time. when I relaunch the app list is loaded properly. Sorry for angular/Ionic questions on this post. I am still learning.

Jan-Pieter van den Heuvel

unread,
Feb 8, 2016, 5:57:34 AM2/8/16
to plot-...@googlegroups.com
Hi Nilesh,

Please keep in mind that the first time the app is started after being installed and when a segmentation property is changed it may take a while before the new notifications are loaded on the device. I would therefore advise to use a manual or automatic refresh of the loaded notifications in your UI. Furthermore you can use console logging to determine whether our plugin returns an empty list (when the notifications are not yet loaded) or whether it does return something but it is not being displayed.
Hope this helps.

Kind regards,
Jan-Pieter

--
You received this message because you are subscribed to the Google Groups "plot-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plot-users+...@googlegroups.com.
Visit this group at https://groups.google.com/group/plot-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/plot-users/d59e351d-f20c-4a4e-8306-1a61d94bd85e%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jan-Pieter van den Heuvel
Plot Projects I Development



Follow us on Twitter
Find and connect with us on Facebook
Keep up with us on our blog

Reply all
Reply to author
Forward
0 new messages